设置应用程序的默认主页 [英] Set application as default home

查看:247
本文介绍了设置应用程序的默认主页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的应用程序为默认主页,一切都会好的,但如果我设置发射器为默认主页被我的应用程序(错误),那么我的应用程序从不要求设置我的应用程序为默认值,直接打开发射家。我想直到我的应用程序设置为默认主页它要求用户设置为默认。请帮助

I have set my application as default home, Everything is going good but if i set Launcher as default home by my application(by mistake), then my app never ask to set my app as default and directly opens the Launcher home. I want that until my app is set as default home it ask user to set as default. Please help

先谢谢了。

推荐答案

您可以通过这块code的检查当前的默认启动:

You can check current default launcher by this piece of code:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.addCategory(Intent.CATEGORY_HOME);
    ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
    String currentHomePackage = resolveInfo.activityInfo.packageName;

在这个答案显示:<一href=\"http://stackoverflow.com/questions/10344824/how-can-i-get-the-package-name-of-the-current-launcher-in-android-2-3-and-above\">How我可以在Android 2.3及以上得到当前发射的包名?

所以,简单地检查是否 currentHomePackage 等于应用的程序包和采取相应的行动。

So simply check if currentHomePackage equals your App's Package and act accordingly.

如果用户设置另一个应用程序为默认启动的对话框选择一个默认的启动只会再次出现,如果他delets的发射器默认设置或删除/安装一个应用程序,可以为默认启动程序行事。

If the user sets another App as Default Launcher the Dialog to choose a Default Launcher would only appear again if he delets the Launchers Defaults or removes/installs an App which can act as default launcher.

这篇关于设置应用程序的默认主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆