Android隐藏的应用程序图标出现在主屏幕上

时间:2014-09-04 07:00:11

标签: android

因此我想在第一次运行后隐藏启动器中的图标。图标从启动器中消失,但仍然出现在主屏幕上。

我见过类似的应用程序 - 他们可以从启动器应用程序列表中删除自己的图标。他们的图标也不会出现在主屏幕上。

我使用以下代码来隐藏应用图标。我弄错了什么?为什么app图标出现在主屏幕上?

 PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName(this,
            com.aaa.xxx.dex.abc.class);

p.setComponentEnabledSetting(componentName,
            PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);

注意:图标从主屏三星Galaxy S4 mini(4.4.2)消失,但它出现在三星Galaxy S3(4.3.0)的主屏幕上。任何建议,帮助赞赏

提前谢谢你..

1 个答案:

答案 0 :(得分:0)

public void HideApp()
      {
        Intent localIntent = new Intent(cx.getApplicationContext(), yourClassName.class);
        cx.getApplicationContext().startService(localIntent);
        cx.getPackageManager().setComponentEnabledSetting(newComponentName(cx,yourClssName.class), 2, 1);
}




public void Appear()
      {
        PackageManager pm = context.getApplicationContext().getPackageManager(); 
            pm.setComponentEnabledSetting(new ComponentName(context, yourClassName.class), 
                    PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
}