try {
Intent intent = new Intent();
intent.setAction("android.settings.APP_NOTIFICATION_SETTINGS");
intent.putExtra("app_package", getPackageName());
intent.putExtra("app_uid", getApplicationInfo().uid);
startActivity(intent);
} catch (ActivityNotFoundException e) {
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
Uri uri = Uri.fromParts("package", getPackageName(), null);
intent.setData(uri);
startActivity(intent);
}
注:
先打開應(yīng)用的通知設(shè)置頁(5.0系統(tǒng)以上可用堪澎,但是非官方蒿讥,不保證好用)供常,如果打不開尾组,就打開應(yīng)用的設(shè)置頁磷箕。
援引自?any-way-to-link-to-the-android-notification-settings-for-my-app
1) This intent relies oninternal/hiddencode of the Settings app, so there's no guarantee that in the future the Settings app won't change and no longer use the same String action, component, or Intent extras to open the app specific notification screen.
2) This method isnot completely backward compatible. The String action and components used were introduced about 2 years ago.