How to programmatically display "Clear Defaults"?

Now I am working on the Home Launcher application. I want to clear the defaults for starting a home (e.g. Samsung Home). those. I want to programmatically display Settings-> Applications->Manage Application->Samsung Home->clear defaults .

How to show this through code?

Thanks at Advance

+3
source share
2 answers

NOTE. . Since this question is limited to accessing the "Manage Application Settings" options, my answer covers just that. You will need to figure out a way to get the actual package name.

In addition, if the idea is to also automatically clear the default values ​​using code, this, as far as I know, cannot be done. Someone can fix me if I'm wrong.

At the same time, this code fragment will open a specific application "Application Screen Management" from your application (the name of the package must be indicated).

 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 name of the Google Maps application package is com.google.android.apps.maps , replace THE_APP_PACKAGE_NAME with it and the code will open the "Application Management" screen for the Google Maps application.

UPDATE:

PackageManager has a clearPackagePreferredActivities method used to clear the code by default. However, this does not seem to work on newer versions of Android: fooobar.com/questions/1486753 / ...

Other posts worth reading:

+6
source

Just for the full image, to get "THE_APP_PACKAGE_NAME" you can use something like this:

  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; 
0
source

Source: https://habr.com/ru/post/1486758/


All Articles