SettingsFragment.java 文件源码

java
阅读 40 收藏 0 点赞 0 评论 0

项目:AlwaysOnDisplayAmoled 作者:
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;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号