3

Now i am working on a Home Launcher application.I want to clear defaults of default home launcher(eg: Samsung Home). ie.I want to show Settings-> Applications->Manage Application->Samsung Home->clear defaults programmatically.

How to show this through code?

Thanks in Advance

braX
  • 11,506
  • 5
  • 20
  • 33
Devu Soman
  • 2,246
  • 13
  • 36
  • 57
  • You should **NOT** do this and instead ask the user to do that action. @DevuSoman – JoxTraex Apr 04 '13 at 04:46
  • See http://stackoverflow.com/questions/2828224/programmatically-unset-a-default-application – CrandellWS Jan 13 '17 at 12:09
  • I think that if you install an app that handles this intent, the OS automatically resets the default, so if even after that, the user chose an app to be the default, you could disable&enable the activity that handles this intent, and it will be reset again. – android developer Jan 28 '17 at 07:52

2 Answers2

6

NOTE: Since this question is limited to accessing the Manage Application Settings options, my answer covers just that. You will have to figure out a way of getting the actual Package Name.

Also, if the idea is to also Clear the Defaults automatically via code, then that, to the best of my knowledge, cannot be done. Someone can correct me if I am wrong on this.

That being said, this piece of code will open the specific application's Manage Application screen from your app (the package name must be supplied).

Intent showSettings = new Intent();
showSettings.setAction(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uriAppSettings = Uri.fromParts("package", "THE_APP_PACKAGE_NAME", null);
showSettings.setData(uriAppSettings);
startActivity(showSettings);

For example, if the package name of the Google Maps application is com.google.android.apps.maps, the replace THE_APP_PACKAGE_NAME with it and the code will open the Manage Application screen for the Google Maps application.

UPDATE:

The PackageManager has a method, clearPackagePreferredActivities used to clear the default via code. However, that doesn't seem to work in newer Android versions: https://stackoverflow.com/a/10246711/450534

Other posts worth reading:

  1. https://stackoverflow.com/a/7750187/450534
  2. https://groups.google.com/forum/?fromgroups=#!topic/android-developers/Rzv8VU-EUAw
Community
  • 1
  • 1
Siddharth Lele
  • 27,623
  • 15
  • 98
  • 151
0

Just for complete the picture, for getting "THE_APP_PACKAGE_NAME" youc can use something like that :

 Intent intent = new Intent(Intent.ACTION_MAIN);
 intent.addCategory(Intent.CATEGORY_HOME);
 ResolveInfo resolveInfo = getPackageManager().resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
 String packageName = resolveInfo.activityInfo.packageName;
yshahak
  • 4,996
  • 1
  • 31
  • 37