The preferencescreen in the setting can be displayed on the setting interface and the activity can be started. The following describes how to start the activity.
1. Start activity in preferencescreen
For example, wireless_setting.xml contains the following fragments:
<Preferencescreen xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: settings = "http://schemas.android.com/apk/res/com.seedshope.android"> <preferencescreen Android: Key = "wifi_settings" Android: Title = "@ string/wifi_settings" Android: summary = "@ string/wifi_settings_summary"> <intent Android: Action = "android. intent. action. main "Android: targetpackage =" com. android. settings "Android: targetclass =" com. android. settings. wiFi. wifisettings "/> </preferencescreen>
Com. Android. settings is the package name of the project, and COM. Android. settings. Wifi. wifisettings is the class to be started. In addition, xmlns: settings is not acceptable (what is its function ?).
In general, it is okay to click the corresponding preference to start the corresponding activity. However, in this case, sometimes the corresponding activity may not be started, because it is related to the callback function onpreferencetreeclick, sometimes we will rewrite this method as follows:
Public Boolean onpreferencetreeclick (preferencescreen, preference) {If (preference = mairplanemodepreference) & (Boolean. parseboolean (systemproperties. get (telephonyproperties. property_inecm_mode) {// in ECM mode launch ECM app dialog startactivityforresult (new intent (telephonyintents. action_show_notice_ecm_block_others, null), request_code_exit_ecm); Return true;} else {// Let the intents be launched by the preference manager return false ;}}
wirelesssetting. java has the above function. If the returned value is true, you will not jump to the activity when you click preference. You can jump to the activity normally only when the returned value is false, because the actual implementation of clicking a preference is in preference. java's javasmclick function is as follows:
Void complete mclick (preferencescreen) {If (! Isenabled () {return;} onclick (); If (monclicklistener! = NULL & monclicklistener. onpreferenceclick (this) {return;} preferencemanager = getpreferencemanager (); If (preferencemanager! = NULL) {preferencemanager. onpreferencetreeclicklistener listener = preferencemanager. getonpreferencetreeclicklistener (); If (preferencescreen! = NULL & listener! = NULL & listener. onpreferencetreeclick (preferencescreen, this) {return ;}} if (mintent! = NULL) {context = getcontext (); context. startactivity (mintent );}}