检查Android系统的安全性通告访问编程设置 [英] Checking Android System Security Notification Access setting programmatically

查看:262
本文介绍了检查Android系统的安全性通告访问编程设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检查以下设置是否启用或Android的编程方式禁用?

 设置>安全>设备管理>通知接入>我的应用

目前我正在调用的设置从我的应用程序通过以下方法对话框但是如果设置已启用然后我不想present此设置。

 意向意图=新意图(android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
startActivity(意向);


解决方案

使简单

 如果(Settings.Secure.getString(this.getContentResolver(),\"enabled_notification_listeners\").contains(getApplicationContext().getPackageName()))
    {
        //服务已启用做点什么
    }其他{
        //服务未启用尝试通过打电话来启用...
       getApplicationContext()。startActivity(新意图(
            android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS));
    }

根据你的问题'其他'部分是可选

Is there a way to check whether the below setting is enabled or disabled programmatically in Android?

Settings > Security > Device Administration > Notification Access > My App 

Currently I'm invoking the settings dialog from my app through the below method but if the settings are already enabled then I dont want to present this settings.

Intent intent = new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS");
startActivity(intent);

解决方案

Make it simple

  if (Settings.Secure.getString(this.getContentResolver(),"enabled_notification_listeners").contains(getApplicationContext().getPackageName())) 
    {
        //service is enabled do something
    } else {
        //service is not enabled try to enabled by calling...
       getApplicationContext().startActivity(new Intent(
            "android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));
    }

'else' part is optional according your question

这篇关于检查Android系统的安全性通告访问编程设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆