Hide Android app icon programmatically takes longer than expected (~ ~ 9 seconds)

Hiding the Android app icon from the Android app list programmatically works correctly, but hiding (almost 9-10 seconds) takes a long time.

I used below code to hide and show the app:

PackageManager p = getPackageManager();
    ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class); // activity which is first time open in manifiest file which is declare as <category android:name="android.intent.category.LAUNCHER" />
p.setComponentEnabledSetting(componentName,PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

      

Here's how to get the app icon back.

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(this, com.apps.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE

      

Is there a faster way to do this? Or is it okay?

+3


source to share





All Articles