我正在创建一个Android无障碍服务哪个调用执行全局动作() at onStartCommand()
public int onStartCommand(Intent intent, int flags, int startId) {
Log.d("service", "started");
Bundle extras = intent.getExtras();
Integer value = -1;
if (extras != null) {
value = extras.getInt("control");
}
switch(value) {
case BUTTON_EVENT_BACK:
//press back button
boolean result = performGlobalAction(GLOBAL_ACTION_BACK);
Log.d("make back action result: ", Boolean.toString(result));
break;
}
stopSelf();
return Service.START_STICKY;
}
我按照指南操作并向清单添加了必要的权限。
<service android:name=".MyAccessibilityService"
android:label="@string/app_name"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
and
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE" />
所以我的问题是为什么函数调用返回 false。缺什么?顺便说一下,后退按钮按下事件没有发生。
在手机的系统设置 - >辅助服务中,我必须启用我的应用程序。之后它就开始工作了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)