Was AccessibilityService changed in Android Pie?

给你一囗甜甜゛ 提交于 2019-12-11 08:27:43

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!