再次加载桌面应用? [英] Load launcher app again?

查看:179
本文介绍了再次加载桌面应用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,因为:
我有一个自定义启动。当我安装它(第一时间开),并使用code。通过code加载意图选择默认启动:

I have a problem as: I have a custom launcher. When i install it (open the first time) and use code to load intent choice default launcher by code:

Intent localIntent = new Intent(Intent.ACTION_MAIN);
localIntent.addCategory(Intent.CATEGORY_HOME);
localIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(localIntent);

我的应用程序会显示为我所有发射的意图。然后,我选择其他发射器(不是我的发射器),并将其设置为默认 - >去(只是选择了我的发射器)的默认场景。那么下一次我跑我发射意图(选择默认发射器)不会再次运行,我不能选择我的发射器为默认值。如何我不能修复它?

My app will show the intent for all my launcher. Then i choice other launcher (not my launcher) and set it to default -> go to the default scene (of my launcher just chosen). Then the next time i run my launcher intent (to choice default launcher) not run again and i can't choice my launcher to default. How to i can't fix it?

我只是做了

private void callIntenChoiceLauncher(Context c) 
{
    PackageManager p = getPackageManager();
    ComponentName cN = new ComponentName(c, RunDefaultLauncher.class);
    p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);

    Intent selector = new Intent(Intent.ACTION_MAIN);
    selector.addCategory(Intent.CATEGORY_HOME);        
    c.startActivity(selector);

    p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
}

但没有任何变化!

but nothing change!!

谢谢指教。

推荐答案

在此code:

c.startActivity(selector);
p.setComponentEnabledSetting(cN, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

当你调用 startActivity(),该活动不会立即启动

。这样做是只需告诉Android框架,你想在这个框架内得到控制权在未来的时间内启动另一个活动。在接下来的线,这样,当Android框架去启动活动,你的发射器部分已经再次被禁用禁用的组件。

when you call startActivity(), the activity isn't started immediately. What this does is just tell the Android framework that you would like to start another activity at the next possible time that the framework gets control. In the next line you disable the component so that when the Android framework goes to start the activity, your launcher component has been disabled again.

要调用 startActivity() 不同步

这篇关于再次加载桌面应用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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