Platform: RK3368
OS: Android 6.0
Kernel: 3.10.0
有时候应用需要跳转到系统设置界面,需要让设置的ActionBar上显示返回按键,则Intent需要额外添加EXTRA_SHOW_FRAGMENT_AS_SUBSETTING。
public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
":settings:show_fragment_as_subsetting";
private void startActivityAsSubSetting(String pkg, String cls) {
Intent intent = new Intent();
intent.setComponent(new ComponentName(pkg, cls));
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.putExtra(EXTRA_SHOW_FRAGMENT_AS_SUBSETTING, true);
try {
startActivity(intent);
} catch (ActivityNotFoundException ex) {
ex.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
例如:跳转到蓝牙设置
startActivityAsSubSetting("com.android.settings",
"com.android.settings.Settings$BluetoothSettingsActivity");