安卓如何打开设置页面
运行指令查看运行页面包名和页面名字
adb shell dumpsys activity activities 通过ADB查看当前Activity指令
使用场景:
安卓由于各个版本不同,需要打开设置页面,方法也各不相同。
使用这个指令可以查看各个机型的设置页面名字及包名,从而正确的打开设置页面。
private void goIntentSetting() {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", mContext.getPackageName(), null);
intent.setData(uri);
try {
mContext.startActivity(intent);
} catch (Exception e) {
e.printStackTrace();
}
}
try {
Intent intent = new Intent(packageName);
ComponentName comp = new ComponentName("包名", "设置页面路径");
intent.setComponent(comp);
mContext.startActivity(intent);
} catch (Exception e) {
Toast.makeText(mContext, "跳转失败", Toast.LENGTH_LONG).show();
e.printStackTrace();
goIntentSetting();
}