Android 設(shè)置相關(guān)頁面
本文主要記錄下android 中跳轉(zhuǎn)設(shè)置相關(guān)頁面的一些action.
在android 中,我們一般使用intent+指定的action來跳轉(zhuǎn)相關(guān)設(shè)置頁面.
1: WLAN
Action 設(shè)置為Settings.ACTION_WIFI_SETTINGS ,用戶可以跳轉(zhuǎn)wifi設(shè)置頁面.
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS);
startActivity(intent);
2: 移動網(wǎng)絡(luò)設(shè)置
Action 設(shè)置為 Settings.ACTION_DATA_ROAMING_SETTINGS, 用戶可以跳轉(zhuǎn)sim卡與流量管理相關(guān)頁面.
Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
startActivity(intent);
3: 藍(lán)牙頁面
Action 設(shè)置為 Settings.ACTION_BLUETOOTH_SETTINGS,用戶可在該頁面連接,搜索,匹配藍(lán)牙設(shè)備
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intent);
4: 輔助功能頁面
Action 設(shè)置為ACTION_ACCESSIBILITY_SETTINGS,用戶可跳轉(zhuǎn)輔助功能或者無障礙頁面
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
startActivity(intent);
5: 應(yīng)用管理
Settings.ACTION_APPLICATION_SETTINGS ,用戶可以跳轉(zhuǎn)應(yīng)用管理/應(yīng)用列表頁面,方便用戶更改應(yīng)用設(shè)置.
Intent intent = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
startActivity(intent);
6: GPS
ACTION_LOCATION_SOURCE_SETTINGS:用戶可以跳轉(zhuǎn)位置管理頁面, 可以在該頁面啟用禁用位置服務(wù).
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
startActivity(intent);
7: 時間與日期
ACTION_DATE_SETTINGS:用戶可以跳轉(zhuǎn)時間與日期界面, 可修改時區(qū)等.
Intent intent = new Intent(Settings.ACTION_DATE_SETTINGS);
startActivity(intent);
8: 安裝未知來源
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS);
startActivity(intent);
9: 開發(fā)者選項(xiàng)
ACTION_APPLICATION_DEVELOPMENT_SETTINGS:用戶可以快捷的跳轉(zhuǎn)開發(fā)者選項(xiàng)頁面,注意: 開發(fā)者選項(xiàng)需要開啟.
Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
startActivity(intent);
10: 輸入法
ACTION_INPUT_METHOD_SETTINGS: 用戶可以跳轉(zhuǎn)輸入法管理頁面.
Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS);
startActivity(intent);
11: 關(guān)于手機(jī)
ACTION_DEVICE_INFO_SETTINGS: 跳轉(zhuǎn)設(shè)備詳情頁面.
Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS);
startActivity(intent);
12: 添加賬號
Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT);
startActivity(intent);
13: 用戶和賬戶
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS);
startActivity(intent);
14: 語言
Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS);
startActivity(intent);
由于各種設(shè)置頁面的跳轉(zhuǎn)統(tǒng)一都是使用的intent+action.
所以我們最后封裝下方法:
private boolean startAction(Context context, String action) {
final Intent intent = new Intent(action);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
context.startActivity(intent);
return true;
} catch (Throwable e) {
Log.e("xxxxx", "startAction: ", e);
return false;
}
}
本文由博客一文多發(fā)平臺 OpenWrite 發(fā)布懊缺!