1

I need to hide my icon application from menu, I have tried this

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName(Test.this,com.example.MainActivity.class);
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

but it doesn't work...how can i do it?

Hamid Shatu
  • 9,664
  • 4
  • 30
  • 41
user3437592
  • 59
  • 3
  • 9
  • "but it doesn't work... ", which problem are you facing? – Sanket Shah May 21 '14 at 10:57
  • The icon is enabled anyway? Try link. It should help. http://stackoverflow.com/questions/19114439/android-hide-unhide-app-icon-programmatically Note that the icon may not be gone until the next reboot. – Martynas May 21 '14 at 10:59
  • Not work...The icon not disappear from menu! – user3437592 May 21 '14 at 11:37
  • Reboot your device after running the above code. There is no requirement for a home screen implementation to necessarily detect this change on the fly. – CommonsWare May 21 '14 at 11:53
  • I have read that this features has been removed from kitkat, but for example in cerberus app it works – user3437592 May 21 '14 at 17:17

1 Answers1

-1

You have made a mistake in the syntax. Change it as given below:

PackageManager p = getPackageManager();
ComponentName componentName = new ComponentName("com.example","com.example.MainActivity");
p.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);

It will work like a charm!!

nidhi_adiga
  • 1,114
  • 1
  • 16
  • 27
athira09
  • 155
  • 1
  • 3
  • 18