问题
I have this AccessibilityService class working in Android Oreo (API 27) and before:
AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.google.test.testaccessibility">
<application
android:icon="@mipmap/ic_launcher"
android:label="TestAccessibility">
<service
android:name=".TestAccessibility"
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/test_accessibility" />
</service>
</application>
test_accessibility.xml
<?xml version="1.0" encoding="utf-8"?>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeViewTextChanged"
android:accessibilityFeedbackType="feedbackGeneric"
android:accessibilityFlags="flagDefault"
android:canRetrieveWindowContent="true"
android:notificationTimeout="10" />
TestAccessibility.java package com.google.test.testaccessibility;
import android.accessibilityservice.AccessibilityService;
import android.util.Log;
import android.view.accessibility.AccessibilityEvent;
public class TestAccessibility extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
Log.d("TestAccessibility", "onAccessibilityEvent");
}
@Override
public void onInterrupt() {
Log.d("TestAccessibility", "onInterrupt");
}
@Override
protected void onServiceConnected() {
Log.d("TestAccessibility", "onServiceConnected");
}
}
It works and the method onAccessibilityEvent is called everytime a text is changed in any application but, when I run this code in an Android Pie (API 28) only the onServiceConnected one is called. I suppose something has been changed in from API 27 to 28 but I can't find anything on the net. Anyone can give me a clue?
Thank you!
回答1:
It's a reported bug:
https://issuetracker.google.com/issues/117747909
I'll try to update this response with the bug's answer.
回答2:
Nothing changed intentionally, and most services work.
Two things to try: 1) Codelab for accessibility service development: https://codelabs.developers.google.com/codelabs/developing-android-a11y-service/index.html
2) Removing the notificationTimeout
来源:https://stackoverflow.com/questions/53290729/was-accessibilityservice-changed-in-android-pie