简体   繁体   中英

How do you dynamically change intent.category.LAUNCHER to intent.category.DEFAULT?

I need to create an application which will be hidden from the user. But before it gets hidden, I need to set some configuration on the GUI and after that I must hide the icon from the applications list. If I remove the

<category android:name="android.intent.category.LAUNCHER" />

the application is not shown on the application list. But my configuration GUI is also not shown. I need to show an Activity and after I make my configuration then I hide the application. I've searched here around but I have been unable to find a solution. How can I dynamically change

<category android:name="android.intent.category.LAUNCHER" />
to
<category android:name="android.intent.category.DEFAULT" /> ?

You could try using two activities, one with android.intent.category.DEFAULT and one with android.intent.category.LAUNCHER, then use the PackageManager's setComponentEnabledSetting() method to disable the launcher activity. According to the doc, "Set the enabled setting for a package component (activity, receiver, service, provider). This setting will override any enabled state which may have been set by the component in its manifest."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM