歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Android應用程序跳轉到系統的各個設置頁面

Android應用程序跳轉到系統的各個設置頁面

日期:2017/3/1 10:17:03   编辑:Linux編程

在開發過程中,當我們的程序檢測到某個功能項沒打開或者沒設置的時候,需要我們在程序中跳轉設置頁面供用戶設置後返回我們的程序才能用我們程序的某一功能,這樣,我們就有必要去了解以下內容:

在Android SDK文檔中有這樣一個類,android.provider.Settings類提供android系統各個頁面的跳轉常量:

使用實例例:startActivity(new Intent(Settings.ACTION_WIRELESS_SETTINGS)),即可跳到android手機網絡設置頁面。

如果要launch Mobile Networks Setting頁面按如下方法:
Intent intent=new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
ComponentName cName = new ComponentName(“com.android.phone”,”com.android.phone.Settings”);
intent.setComponent(cName);
startActivity(intent);

如果要進入Networks Operators頁面按如下方法:
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClassName(“com.android.phone”, “com.android.phone.NetworkSetting”);
startActivity(intent);

以上為網上提供的跳轉方法是從自己軟件的包名跳轉到系統的包名,大家都知道,android特別的爛,時不時改變程序的結構,不同版本可能包名什麼不一樣的,此外,android應用層的包名若是不知道,則無法跳轉,經不認真測試,好像會報錯,個人感覺也是特別的麻煩。然而android為我們提供比startActivity更加簡便的方法,就是startActivityForResult,使用startActivityForResult跳轉設置頁面設置完成後還可以返回自己的程序頁面。下面是個人的實現方法:

比如,我要跳轉系統”輔助功能“設置頁面,則用一下代碼即可:

Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(intent, REQUESTCODE);

備注:REQUESTCODE為聲明的靜態 int 型常量

==================== 以下為跳轉個設置頁面的參數 =============================

Constants String ACTION_ACCESSIBILITY_SETTINGS Activity Action: Show settings for accessibility modules. String ACTION_ADD_ACCOUNT Activity Action: Show add account screen for creating a new account. String ACTION_AIRPLANE_MODE_SETTINGS Activity Action: Show settings to allow entering/exiting airplane mode. String ACTION_APN_SETTINGS Activity Action: Show settings to allow configuration of APNs. String ACTION_APPLICATION_DETAILS_SETTINGS Activity Action: Show screen of details about a particular application. String ACTION_APPLICATION_DEVELOPMENT_SETTINGS Activity Action: Show settings to allow configuration of application development-related settings. String ACTION_APPLICATION_SETTINGS Activity Action: Show settings to allow configuration of application-related settings. String ACTION_BLUETOOTH_SETTINGS Activity Action: Show settings to allow configuration of Bluetooth. String ACTION_DATA_ROAMING_SETTINGS Activity Action: Show settings for selection of 2G/3G. String ACTION_DATE_SETTINGS Activity Action: Show settings to allow configuration of date and time. String ACTION_DEVICE_INFO_SETTINGS Activity Action: Show general device information settings (serial number, software version, phone number, etc.). String ACTION_DISPLAY_SETTINGS Activity Action: Show settings to allow configuration of display. String ACTION_INPUT_METHOD_SETTINGS Activity Action: Show settings to configure input methods, in particular allowing the user to enable input methods. String ACTION_INPUT_METHOD_SUBTYPE_SETTINGS Activity Action: Show settings to enable/disable input method subtypes. String ACTION_INTERNAL_STORAGE_SETTINGS Activity Action: Show settings for internal storage. String ACTION_LOCALE_SETTINGS Activity Action: Show settings to allow configuration of locale. String ACTION_LOCATION_SOURCE_SETTINGS Activity Action: Show settings to allow configuration of current location sources. String ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS Activity Action: Show settings to manage all applications. String ACTION_MANAGE_APPLICATIONS_SETTINGS Activity Action: Show settings to manage installed applications. String ACTION_MEMORY_CARD_SETTINGS Activity Action: Show settings for memory card storage. String ACTION_NETWORK_OPERATOR_SETTINGS Activity Action: Show settings for selecting the network operator. String ACTION_NFCSHARING_SETTINGS Activity Action: Show NFC Sharing settings. String ACTION_NFC_SETTINGS Activity Action: Show NFC settings. String ACTION_PRIVACY_SETTINGS Activity Action: Show settings to allow configuration of privacy options. String ACTION_QUICK_LAUNCH_SETTINGS Activity Action: Show settings to allow configuration of quick launch shortcuts. String ACTION_SEARCH_SETTINGS Activity Action: Show settings for global search. String ACTION_SECURITY_SETTINGS Activity Action: Show settings to allow configuration of security and location privacy. String ACTION_SETTINGS Activity Action: Show system settings. String ACTION_SOUND_SETTINGS Activity Action: Show settings to allow configuration of sound and volume. String ACTION_SYNC_SETTINGS Activity Action: Show settings to allow configuration of sync settings. String ACTION_USER_DICTIONARY_SETTINGS Activity Action: Show settings to manage the user input dictionary. String ACTION_WIFI_IP_SETTINGS Activity Action: Show settings to allow configuration of a static IP address for Wi-Fi. String ACTION_WIFI_SETTINGS Activity Action: Show settings to allow configuration of Wi-Fi. String ACTION_WIRELESS_SETTINGS Activity Action: Show settings to allow configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks. String AUTHORITY String EXTRA_AUTHORITIES Activity Extra: Limit available options in launched activity based on the given authority. String EXTRA_INPUT_METHOD_ID

以上為2012-7-12在android開發文檔中截取的參數,最新參數請關注android官網的開發文檔http://developer.android.com/reference/android/provider/Settings.html

Copyright © Linux教程網 All Rights Reserved