简体   繁体   English

如何检查用户是否在Android中启用了通知辅助功能?

[英]How to check notification accessibility service is enabled or not by user in Android?

How to check notification accessibility service is enabled or not by user in android ? 如何检查用户是否在Android中启用了通知可访问性服务?

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

I have tried this code but this is not working. 我已经尝试过此代码,但这无法正常工作。

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. 如果服务当前正在运行,它将返回true,否则返回false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android辅助功能检测通知 - Android accessibility service detect notification 如何检查启用或禁用的辅助功能,然后在 android 中相应地更改视图? - How to check accessibility enabled or disabled and then change the view accordingly in android? Android-如何检查是否启用了打印服务? - Android - How to check if a Print Service is enabled? Android可访问性服务未在Oreo中接收通知 - Android Accessibility Service not receiving Notification in oreo 如何使用 android 无障碍服务来检测用户触摸了哪个视图? - How to use an android accessibility service to detect which view the user touched? 如何在 Android 中检查其他应用程序是否使用辅助功能(BIND_ACCESSIBILITY_SERVICE)权限 - How to Check other apps are using accessibility (BIND_ACCESSIBILITY_SERVICE) permission or not in Android 如何检测android上的辅助功能设置是否启用/禁用 - how to detect accessibility settings on android is enabled/disabled Android取消固定屏幕-即使启用了某些辅助功能,如何始终需要两个键 - Android unpinning screen - how to require always two keys even if some accessibility service is enabled 辅助功能服务通知已删除 - Accessibility service notification removed React Native 检查是否在 Android 上启用了应用通知 - React Native check if app notification enabled on Android
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM