0

How to check notification accessibility service is enabled or not by user in android ?

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

I have tried this code but this is not working.

Jonas Czech
  • 12,018
  • 6
  • 44
  • 65
Nazima Kauser MMF
  • 1,635
  • 3
  • 14
  • 11

1 Answers1

2

You can try following code to check weather your service is running or not:

    public boolean isMyServiceRunning(Activity activity) {
    ActivityManager manager = (ActivityManager) activity
            .getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager
            .getRunningServices(Integer.MAX_VALUE)) {
        if (NotificationService.class.getName().equals(
                service.service.getClassName())) {
            return true;
        }
    }

    return false;
}

It will return true if service is running currently otherwise its return false.

BSavaliya
  • 809
  • 1
  • 16
  • 26