private boolean checkNotificationsPermission(Context c, boolean prompt) {
ContentResolver contentResolver = c.getContentResolver();
String enabledNotificationListeners = Settings.Secure.getString(contentResolver, "enabled_notification_listeners");
String packageName = c.getPackageName();
// check to see if the enabledNotificationListeners String contains our package name
if (enabledNotificationListeners == null || !enabledNotificationListeners.contains(packageName)) {
((SwitchPreference) findPreference("notifications_alerts")).setChecked(false);
if (Utils.isAndroidNewerThanL() && prompt) {
Intent intent = new Intent(Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
checkAndStartActivity(intent);
shouldEnableNotificationsAlerts = true;
} else if (prompt) {
checkAndStartActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
shouldEnableNotificationsAlerts = true;
}
return false;
}
return true;
}
SettingsFragment.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:AlwaysOnDisplayAmoled
作者:
评论列表
文章目录