开发者

Add / Remove App Drawer Shortcuts

开发者 https://www.devze.com 2023-02-12 16:56 出处:网络
I am trying to programmatically add and remove application shortcuts from the app drawer. I understand the app drawer knows which applications should be presented by using an intent filter with the LA

I am trying to programmatically add and remove application shortcuts from the app drawer. I understand the app drawer knows which applications should be presented by using an intent filter with the LAUNCHER category.

I would like to be able to add/remove shortcuts to specific activities in my application, according to dynamic conditions, which is why I can't have them simply in my manifest开发者_开发百科 file.

Thank you.


As far as I know, this is not possible. Unfortunately, with the current Android API level there is no way to add IntentFilters to Activity objects through code. Check out this doc on intent filters. Relevant quote:

An intent filter is an instance of the IntentFilter class. However, since the Android system must know about the capabilities of a component before it can launch that component, intent filters are generally not set up in Java code, but in the application's manifest file (AndroidManifest.xml) as elements. (The one exception would be filters for broadcast receivers that are registered dynamically by calling Context.registerReceiver(); they are directly created as IntentFilter objects.)

0

精彩评论

暂无评论...
验证码 换一张
取 消