Android how to programmatically hide launcher icon

前端 未结 5 1760
孤独总比滥情好
孤独总比滥情好 2020-11-28 21:22

my app is designed to only need to be run once. As such I want to hide the icon from the launcher after the first run, but without uninstalling the app.

I have seen

5条回答
  •  被撕碎了的回忆
    2020-11-28 22:00

    PackageManager p = getPackageManager();
    p.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
    

    Note that the icon may not be gone until the next reboot.

提交回复
热议问题