0

I know there is a way to hide app icon in Android 9(API 28) and lower. But is there a work around to make the same happen in Android 10(Api 29).

The code below doesn't work for API 29.

         val p: PackageManager? = context?.packageManager
            val componentName = context?.let {
                ComponentName(
                    it,
                    MainActivity::class.java
                )
            } // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />

            if (componentName != null) {
                p?.setComponentEnabledSetting(
                    componentName,
                    PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP
                )
            }
Darotudeen
  • 1,914
  • 4
  • 21
  • 36
  • Presumably, the mandatory launcher icon is there to help prevent malware from hiding from users. – CommonsWare May 06 '22 at 19:10
  • Yeah, I know. Apparently non malware app could use that too. – Darotudeen May 06 '22 at 19:17
  • The question then becomes: are the non-malware uses worth it? Google apparently decided that the answer was "no". You have the `android-automotive` tag on here; if you are working for a car manufacturer, they will have options for pre-installed apps that are not available to ordinary developers. – CommonsWare May 06 '22 at 19:37
  • yes I am working for a car manufacturer. Thanks for your advice. – Darotudeen May 06 '22 at 23:12
  • @CommonsWare Thanks for your advice. Right now it is possible to hide the icon but show the icon back throws Activity not found error which means App as to be re-install. Is there a way to show the icon on the fly? – Darotudeen May 13 '22 at 14:15
  • You might want to ask a separate Stack Overflow question, with a [mcve] showing how you are hiding the icon. We cannot really tell you how to show it if we do not know how you are hiding it. – CommonsWare May 13 '22 at 14:23
  • Yes I have. Here is the link https://stackoverflow.com/questions/72223467/hiding-and-unhiding-app-icon-in-the-launcher – Darotudeen May 13 '22 at 14:33
  • @CommonsWare https://stackoverflow.com/questions/72223467/hiding-and-unhiding-app-icon-in-the-launcher – Darotudeen May 13 '22 at 16:50

0 Answers0