onAccessibilityEvent
从未在Android Pie上调用。
首先,这是我的代码
public class MyAccessibilityService extends AccessibilityService {
@Override
public void onInterrupt() {
}
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
final int eventType = event.getEventType();
switch(eventType) {
case AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED:
Log.e("called called ","nnnnnnnnnnnnnnn TYPE_VIEW_TEXT_CHANGED "+visibility);
show();
break;
case AccessibilityEvent.TYPE_VIEW_FOCUSED:
break;
}
}
@Override
protected void onServiceConnected() {
super.onServiceConnected();
}
@Override
public void onDestroy() {
super.onDestroy();
}
}
这是我的清单服务
<service
android:name=".service.MyAccessibilityService"
class=".MyAccessibilityService"
android:enabled="true"
android:exported="false"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/serviceconfig" />
</service>
和serviceConfig xml
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:description="@string/app_name"
android:accessibilityEventTypes="typeViewTextChanged|typeViewFocused"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="20"
android:canRetrieveWindowContent="true"
/>
onServiceConnected
被无问题调用,并且onDestroy
从未被调用,因此,我的服务也不会被杀死。 onAccessibilityEvent
并未被调用,但是当我在较旧的版本(例如4.4.4
)上对其进行测试时
和7.0
起作用。但是,在Pie onAccessibilityEvent
上永远不会被调用
答案 0 :(得分:0)
要尝试的一件事是删除notificationTimeout。该参数未经充分测试。