Nick Nick - 5 months ago 22
Android Question

Check for access to notifications using NotificationListenerService

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.

Answer

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.

Edit:

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;
}
Comments