"Android system settings-> ApplicationsProgram-> Manage Applications "lists the installed applications in the system. Select one of the programs to go to the "Application
Information (Application
Info) interface. This interface displays the program name, version, storage, permissions, and other information, as well as buttons such as detaching, stopping, and clearing the cache. When writing related programs (such
You can call this panel, which naturally provides great convenience. So how to implement it?
This interface is provided in the latest Android SDK 2.3 (API level 9. In the document path
Docs/reference/Android/provider/settings.html # action_application_details_settings
There is a description like this:
Public static final string action_application_details_settingsSince: API level 9
Activity action: show screen of details about a special application.
In some cases, a matching activity may not exist, so ensure you safeguard against this.
Input:
The intent's data URI specifies the application package name to be
Shown, with the "package" scheme. That is "package: COM. My. app ".
Output: Nothing.
Constant Value: "android. settings. application_details_settings"
That is to say, we only needAndroid. provider. settings. action_application_details_settingsAs action;"Package: package name of the application"As Uri, you can use startactivity to start the application information interface.CodeAs follows:
View plain
- Intent intent =NewIntent (settings. action_application_details_settings );
- Uri uri = URI. fromparts (scheme, packagename,Null);
- Intent. setdata (URI );
- Startactivity (intent );
However, in versions earlier than Android 2.3, there is no public interface. By viewing the source code of the platform/packages/apps/settings. Git program set by the system, you can find that the application information interface is installedappdetails. Here (2.1) And here (2.2), we can see
Android2.1 And
Android2.2 (Management applications. Java) is how to start installedappdetails. View plain
- // Utility method used to start sub Activity
-
- Private VoidStartapplicationdetailsactivity (){
-
- // Create intent to start new activity
-
- Intent intent =NewIntent (intent. action_view );
-
- Intent. setclass (This, Installedappdetails.Class);
- Intent. putextra (app_pkg_name, mcurrentpkgname );
-
- // Start new activity to display extended information
-
- Startactivityforresult (intent, installed_app_details );
-
- }
But constant
App_pkg_nameIs not the same. "PKG" is defined in 2.2, and "com. Android. settings. applicationpkgname" is defined in 2.1" So,
For versions 2.1 and earlier In this way, we can call installedappdetails: view plain
- Intent I =NewIntent (intent. action_view );
- I. setclassname ("Com. Android. Settings","Com. Android. settings. installedappdetails");
- I. putextra ("Com. Android. settings. applicationpkgname", Packagename );
- Startactivity (I );
For 2.2, you only need to replace the first parameter of putextra above with "PKG"
In summary, the common code for calling "application information" is as follows: View plain
- Private Static FinalString scheme ="Package";
-
- /**
-
- * The extra name required to call the system installedappdetails interface (for Android 2.1 and earlier versions)
-
- */
-
- Private Static FinalString app_pkg_name_21 ="Com. Android. settings. applicationpkgname";
- /**
-
- * The extra name required to call the system installedappdetails interface (for Android 2.2)
-
- */
-
- Private Static FinalString app_pkg_name_22 ="PKG";
-
- /**
-
- * Package name of installedappdetails
-
- */
- Private Static FinalString app_details_package_name ="Com. Android. Settings";
-
- /**
-
- * Installedappdetails Class Name
-
- */
-
- Private Static FinalString app_details_class_name ="Com. Android. settings. installedappdetails";
- /**
-
- * Call the installedappdetails interface to display the details of the installed application. For Android 2.3 (API level
-
- * 9) above, use the interfaces provided by the SDK; 2.3 or below, use non-public interfaces (view the source code of installedappdetails ).
-
- *
-
- * @ Param Context
-
- *
-
- * @ Param packagename
-
- * Application package name
- */
-
- Public Static VoidShowinstalledappdetails (context, string packagename ){
-
- Intent intent =NewIntent ();
-
- Final IntApilevel = build. version. sdk_int;
- If(Apilevel> =9){// 2.3 (apilevel 9) or above, use the interface provided by the SDK
-
- Intent. setaction (settings. action_application_details_settings );
-
- Uri uri = URI. fromparts (scheme, packagename,Null);
-
- Intent. setdata (URI );
- }Else{// Use a non-public interface below 2.3 (view the source code of installedappdetails)
-
- // In 2.2 and 2.1, installedappdetails uses different app_pkg_name.
-
- FinalString apppkgname = (apilevel =8? App_pkg_name_22
-
- : App_pkg_name_21 );
- Intent. setaction (intent. action_view );
-
- Intent. setclassname (app_details_package_name,
-
- App_details_class_name );
-
- Intent. putextra (apppkgname, packagename );
-
- }
-
- Context. startactivity (intent );
-
- }