下面列出了android.provider.Settings#ACTION_SETTINGS 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Action getSettingsAction() {
return new SinglePressAction(com.android.internal.R.drawable.ic_settings,
R.string.global_action_settings) {
@Override
public void onPress() {
Intent intent = new Intent(Settings.ACTION_SETTINGS);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
mContext.startActivity(intent);
}
@Override
public boolean showDuringKeyguard() {
return true;
}
@Override
public boolean showBeforeProvisioning() {
return true;
}
};
}
/**
* 打开系统设置界面
*/
public static void openSetting(Activity activity) {
// Intent intent = new Intent("/");
// ComponentName cm = new ComponentName("com.android.settings",
// "com.android.settings.WirelessSettings");
// intent.setComponent(cm);
// intent.setAction("android.intent.action.VIEW");
// activity.startActivityForResult(intent, 0);
//打开移动网络设置界面
// Intent intent = new Intent(Settings.ACTION_DATA_ROAMING_SETTINGS);
// activity.startActivity(intent);
Intent intent = new Intent(Settings.ACTION_SETTINGS);
activity.startActivity(intent);
}
/**
* 获取跳转到系统设置的意图
* @param isNewTask 是否开启新的任务栈
* @return 跳转到系统设置的意图
*/
public static Intent getSystemSettingIntent(final boolean isNewTask) {
try {
Intent intent = new Intent(Settings.ACTION_SETTINGS);
return getIntent(intent, isNewTask);
} catch (Exception e) {
LogPrintUtils.eTag(TAG, e, "getSystemSettingIntent");
}
return null;
}
@Override
protected void onResume() {
super.onResume();
disposable = new CompositeDisposable();
if (nfcManager.verifyNFC())
init();
else {
Intent setnfc = new Intent(Settings.ACTION_SETTINGS);
startActivity(setnfc);
}
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.action_settings:
final Intent intentSettings = new Intent(this, SettingsActivity.class);
startActivity(intentSettings);
return true;
case R.id.action_refresh_app_list:
recreate();
return true;
case R.id.action_system_settings:
final Intent intentSystemSettings = new Intent(Settings.ACTION_SETTINGS);
intentSystemSettings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentSystemSettings);
return true;
case R.id.action_manage_apps:
final Intent intentManageApps = new Intent(Settings.ACTION_APPLICATION_SETTINGS);
intentManageApps.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentManageApps);
return true;
case R.id.action_set_wallpaper:
final Intent intentWallpaperPicker = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(intentWallpaperPicker);
return true;
case R.id.action_about:
final Intent intentAbout = new Intent(this, AboutActivity.class);
startActivity(intentAbout);
return true;
default:
return super.onOptionsItemSelected(item);
}
}
/** 跳转到设置界面 */
public static void setting(@NonNull Context context) {
Intent intent = new Intent(Settings.ACTION_SETTINGS);
context.startActivity(intent);
}
/**
* 跳转到系统设置界面
* @param context
*/
public static void jumpToSystemSetting(Context context) {
Intent toSettingActionIntent = new Intent(Settings.ACTION_SETTINGS);
jumpToActivity(context,toSettingActionIntent,0,false);
}