机器人如何以编程方式隐藏启动图标 [英] Android how to programmatically hide launcher icon

查看:97
本文介绍了机器人如何以编程方式隐藏启动图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序被设计成只需要运行一次。因此我想隐藏的启动图标后第一次运行,但不卸载应用程序。

我已经看到了类似的应用程序 - 它们能够从启动的应用程序列表中删除自己的图标。我怎样才能达到同样的效果?谢谢你。

解决方案

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

请注意,该图标可能不会消失,直到下次重新启动。

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 similar applications - they can remove their own icons from the launcher app list. How can I achieve the same results? Thank you.

解决方案

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.

这篇关于机器人如何以编程方式隐藏启动图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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