Intent for Application Details Page

My application relies heavily on the database for the data, and sometimes the database will not be copied correctly, corrupted, or just throwing away a common template. Clearing the application data and then reopening the application seems to work well, but it is a rather difficult task to ask my users to dig through the settings pages, and I am looking for a way to quickly go to the application details page (which shows delete, move to SD, clear data, etc.)

I found Settings.ACTION_APPLICATION_DETAILS_SETTINGS action, but get an ActivityNotFoundException when I try to run it as described in my wish Z Can someone help me how to sort this correctly?

thanks

EDIT: As noted in the answers, this is only API9 and above, the code I'm using now if someone wants it to be lower. Believe that it works on API3 and higher.

 try { Intent i = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:com.espian.formulae")); startActivity(i); } catch (ActivityNotFoundException ex) { Intent i = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); startActivity(i); } 
+6
source share
2 answers

I will post it as an answer here in addition to my comment. This intention is only available from API level 9 (2.3). Desire Z does not have 2.3 ... yet .;)

+1
source

I know this is too late, but it can help someone. Based on the platform source (froyo), I create one function that opens the settings page for a specific package. It works in an emulator, but I have never tried on a real device. I don't know if it works on API <8.

There he is:

 public boolean startFroyoInstalledAppDetailsActivity(String packagename) { boolean result = false; Intent i = new Intent(); i.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); i.setAction(Intent.ACTION_VIEW); i.putExtra("pkg", packagename); i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { cx.startActivity(i); result = true; } catch (Exception ex) { result = false; } return result; } 

Based on your code, I also create a version of Gingerbread that works on real devices with API levels 9, 10, 11, 12, 13, 14 and 15, but it can be safely called API 8, but in this case it will return false.

There he is:

 public boolean startGingerbreadInstalledAppDetailsActivity(String packagename) { boolean result = false; Intent i = new Intent(); i.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + packagename)); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { cx.startActivity(i); result = true; } catch (Exception ex) { result = false; } return result; } 
+10
source

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


All Articles