android应用隐藏桌面图标

来源:互联网 发布:rss阅读器java源代码 编辑:程序博客网 时间:2024/05/01 08:08

接下来我要说的这种方法可以隐藏图标,同是也可以正常启动运行。

在manifest的入口activity里面intent-filter中设置<data></data>元素。

比如:

<data android:host="AuthActivity" android:scheme="com.android.example" />

注意,android:scheme是大小写敏感的,必须以小写字母开头

也就是这个MainActivity可以响应Uri为com.android.example://AuthActivity的特定 Intent

但是为什么加入这个之后app就不显示图标了呢?

因为我们把app的入口Activity申明为由接收隐士的Intent来启动,这样自然也就不会显示图标了。

好了,如果需要显示图标的话而且也必须响应上述Uri的话,那么我们可以在该Activity中再加入一个intent-filter标签,将data元素移到新建的标签中。这样应用既可以显示图标又可以响应特定的Uri了。

 

参考文章:

http://developer.android.com/guide/topics/manifest/intent-filter-element.html

http://wikidroid.sinaapp.com/AndroidManifest.xml_data


另附调用方法:

Intent intent = new Intent();intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);ComponentName component = new ComponentName(pkgname, value);intent.setComponent(component);startActivity(intent);

文字转载自Android 如何隐藏应用程序的图标,感谢ydt_lwj提供好文章

0 0
原创粉丝点击