How to redirect android to the settings page

Source: Internet
Author: User
How to jump to the system management application interface in Android

1. Enter all the interfaces for managing applications, which have been downloaded and are running three types.

Http://www.linuxidc.com/Linux/2011-10/45203.htm

What if you need to call the system's native management application interface when writing Android applications? I have met in a project, and I have not found a ready-made intent in this aspect, but it is implemented by looking at the source code. Android source code application_settings.xml <preferencescreen Android: Title = "@ string/manageapplications_settings_title" Android: Summary = "@ string/manageapplications_settings_summary"> <intent Android: Action = "android. intent. action. main "Android: targetpackage =" com. android. settings "Android: targetclass =" com. android. settings. manageapplications "/> </preferencescreen> friends who are familiar with preferencescreen should know how to do it. If they are not familiar with it, post an article at the end of the article, according to the XML description, we can use the following code to call the system's native management application interface intent = new intent (); intent. setaction ("android. intent. action. main "); intent. setclassname ("com. android. settings "," com. android. settings. manageapplications "); startactivity (intent );


Introduction and Analysis of preferencescreen in Android settings: http://www.linuxidc.com/Linux/2011-10/45204.htm

2.The "Android system settings-> Applications-> management applications" list lists the installed applications. Select a program to go to the "Application Info" page. This interface shows the processThere are many functions such as sequential names, versions, storage, permissions, and buttons such as detaching, stopping, and clearing the cache. If you can call this panel when writing related programs (such as the task manager), it naturally provides great convenience. So how to implement it?

Http://jykenan.iteye.com/blog/1654925

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_settingsThere is a description like this:

Public static final string action_application_details_settings since: 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 need to use Android. provider. settings. action_application_details_settings as the action; "package: package name of the application" as the URI, we can use startactivity to start the application mailInformation interface. The Code is as follows:

 

Intent intent = new intent (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 how android2.1 and android2.2's Application Management Program (manageapplications. Java) Start installedappdetails.

// Utility method used to start sub Activity

Private void startapplicationdetailsactivity (){

// Create intent to start new activity

Intent intent = new intent (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 );

}

However, the definition of the constant app_pkg_name is different.

"PKG" is defined in 2.2, and "com. Android. settings. applicationpkgname" is defined in 2.1"

For versions 2.1 and earlier, we can call installedappdetails as follows:

View plain

Intent I = new intent (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:

Private Static final string scheme = "package ";

/**

* The extra name required to call the system installedappdetails interface (for Android 2.1 and earlier versions)

*/

Private Static final string app_pkg_name_21 = "com. Android. settings. applicationpkgname ";

/**

* The extra name required to call the system installedappdetails interface (for Android 2.2)

*/

Private Static final string app_pkg_name_22 = "PKG ";

/**

* Package name of installedappdetails

*/

Private Static final string app_details_package_name = "com. Android. Settings ";

/**

* Installedappdetails Class Name

*/

Private Static final string 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 void showinstalledappdetails (context, string packagename ){

Intent intent = new intent ();

Final int apilevel = 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 {// below 2.3, use a non-public interface (view the source code of installedappdetails)

// In 2.2 and 2.1, installedappdetails uses different app_pkg_name.

Final string 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 );

}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.