Remove Application From Launcher Programmatically In Android
Is there a way of removing an activity from the home launcher at runtime? I mean removing Intent.CATEGORY_LAUNCHER from its properties or something similar.
Solution 1:
You can disable a component via PackageManager#setComponentEnabledSetting()
, which will have the effect of removing it from the Launcher.
Solution 2:
Actually from android 10+, it is quite difficult to hide the app launcher icon. I have used the code -
val packageManager = packageManager
**// disable the app launcher icon**val componentName = ComponentName(
this,
MainActivity::class.java
)
packageManager.setComponentEnabledSetting(
componentName,
PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
PackageManager.DONT_KILL_APP
)
**// enable the app launcher icon**val componentName = ComponentName(
this,
MainActivity::class.java
)
packageManager.setComponentEnabledSetting(
componentName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP
)
When the disable code runs, it only make the app launcher icon disabled not hidden. But you cannot launch it, it open the app info setting page when click the launcher icon.
Another way - This is another way to do that, make a app and run it as device owner mode. Then we can able to hide/remove the app launcher icon.
Visit the link- https://www.sisik.eu/blog/android/dev-admin/uninstalling-and-disabling-apps
Post a Comment for "Remove Application From Launcher Programmatically In Android"