Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show 'Clear Defaults' programmatically?

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

like image 555
Devu Soman Avatar asked Jun 17 '26 02:06

Devu Soman


1 Answers

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
like image 184
Siddharth Lele Avatar answered Jun 19 '26 17:06

Siddharth Lele



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!