[英]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.