本文主要记录下android 中跳转设置相关页面的一些action.
在android 中,我们一般使用intent+指定的action来跳转相关设置页面.
Action 设置为Settings.ACTION_WIFI_SETTINGS ,用户可以跳转wifi设置页面.
Intent intent = new Intent(Settings.ACTION_WIFI_SETTINGS); startActivity(intent);
Action 设置为 Settings.ACTION_DATA_ROAMING_SETTINGS, 用户可以跳转sim卡与流量管理相关页面.
Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS); startActivity(intent);
Action 设置为 Settings.ACTION_BLUETOOTH_SETTINGS,用户可在该页面连接,搜索,匹配蓝牙设备
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); startActivity(intent);
Action 设置为ACTION_ACCESSIBILITY_SETTINGS,用户可跳转辅助功能或者无障碍页面
Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS); startActivity(intent);
Settings.ACTION_APPLICATION_SETTINGS ,用户可以跳转应用管理/应用列表页面,方便用户更改应用设置.
Intent intent = new Intent(Settings.ACTION_APPLICATION_SETTINGS); startActivity(intent);
ACTION_LOCATION_SOURCE_SETTINGS:用户可以跳转位置管理页面, 可以在该页面启用禁用位置服务.
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); startActivity(intent);
ACTION_DATE_SETTINGS:用户可以跳转时间与日期界面, 可修改时区等.
Intent intent = new Intent(Settings.ACTION_DATE_SETTINGS); startActivity(intent);
Intent intent = new Intent(Settings.ACTION_SECURITY_SETTINGS); startActivity(intent);
ACTION_APPLICATION_DEVELOPMENT_SETTINGS:用户可以快捷的跳转开发者选项页面,注意: 开发者选项需要开启.
Intent intent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); startActivity(intent);
ACTION_INPUT_METHOD_SETTINGS: 用户可以跳转输入法管理页面.
Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS); startActivity(intent);
ACTION_DEVICE_INFO_SETTINGS: 跳转设备详情页面.
Intent intent = new Intent(Settings.ACTION_DEVICE_INFO_SETTINGS); startActivity(intent);
Intent intent = new Intent(Settings.ACTION_ADD_ACCOUNT); startActivity(intent);
Intent intent = new Intent(Settings.ACTION_SYNC_SETTINGS); startActivity(intent);
Intent intent = new Intent(Settings.ACTION_LOCALE_SETTINGS); startActivity(intent);
由于各种设置页面的跳转统一都是使用的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; } }