是否可以停止或杀死无障碍服务? [英] Can accessibility service be stopped or killed?

查看:668
本文介绍了是否可以停止或杀死无障碍服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经编写了一个可访问性服务,我希望该服务在收到可访问性事件(即方法 onAccessibilityEvent )后被停止/杀死。能做到吗?我试图使用如下所示的kill进程来杀死它,但是它不起作用。

I have written an accessibility service and I want the service to be stopped/killed once it receives an accessibility event (i.e. in method onAccessibilityEvent). Can this be done? I have tried to kill using kill process as below but it is not working.

unbindService(mSvcConn);  
android.os.Process.killProcess(android.os.Process.myPid());

我在AndroidManifest.xml中授予了以下权限

I have given the below permission in AndroidManifest.xml

<uses-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />

我知道无障碍服务无法以编程方式启动,但也不能被停止/杀死吗? / p>

I know that accessibility service cannot be started programmatically but can't it be stopped/killed either?

推荐答案

可访问性服务无法将其自身从已启用服务的列表中删除,或者在不自动重启的情况下终止其自身的进程,但是您可以调用 AccessibilityService.setServiceInfo(new AccessibilityServiceInfo())有效关闭服务。

An accessibility service can't remove itself from the list of enabled services or kill its own process without being automatically restarted, but you can call AccessibilityService.setServiceInfo(new AccessibilityServiceInfo()) to effectively turn off your service.

调用 AccessibilityManager.isEnabled()仍将返回true,但您的服务将不会接收事件。

Calling AccessibilityManager.isEnabled() will still return true, but your service won't receive events.

这篇关于是否可以停止或杀死无障碍服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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