检查访问使用NotificationListenerService通知 [英] Check for access to notifications using NotificationListenerService

查看:225
本文介绍了检查访问使用NotificationListenerService通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是> = 4.3 NotificationListenerService 访问通知。在第一次开始,我的应用程序将用户带到访问通知系统面板,但我想利用用户只要有我在访问通知应用程序的复选框被禁用。我还没有找到一个 isNotificationAccessEnabled() -method任何地方,但我肯定知道,这是可能的,因为喜欢的Krome 做到这一点了。

I'm using the >=4.3 NotificationListenerService to access notifications. On the first start, my app takes the user to the "Access Notifications" system panel, but I'd like to take the user there whenever the checkbox for my app in "Access Notifications" is disabled. I haven't found a isNotificationAccessEnabled()-method anywhere, but I definitely know that it's possible because apps like Krome do this, too.

推荐答案

克罗梅的进出口开发商。我做了什么来检查是否启用服务是添加能够更改到onBind方法真和假的解除绑定公共静态变量。这也就是服务工作。

Im developer of Krome. What have I done to check if service is enabled is add public static variable that changes to true in onBind method and to false in unbind. That is how this service work.

编辑:

public static boolean isNotificationAccessEnabled = false;

@Override
public IBinder onBind(Intent mIntent) {
    IBinder mIBinder = super.onBind(mIntent);
    isNotificationAccessEnabled = true;
    return mIBinder;
}

@Override
public boolean onUnbind(Intent mIntent) {
    boolean mOnUnbind = super.onUnbind(mIntent);
    isNotificationAccessEnabled = false;
    return mOnUnbind;
}

这篇关于检查访问使用NotificationListenerService通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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