2

I have set up an accessibility service based on https://stackoverflow.com/a/36861638/288568 and https://stackoverflow.com/a/34400729/288568 to capture USSD popups (temporarily).

My service info XML looks like this:

 <accessibility-service      xmlns:android="http://schemas.android.com/apk/res/android"
     android:accessibilityEventTypes="typeWindowStateChanged|typeWindowContentChanged"
    android:accessibilityFeedbackType="feedbackGeneric"
    android:accessibilityFlags="flagDefault"
    android:canRetrieveWindowContent="true"
    android:description="@string/accessibility_service_description"
    android:notificationTimeout="100"
    android:packageNames="@null"
    android:enabled="true" />

My onServiceConnected:

@Override
protected void onServiceConnected() {
    Log.d("MyTag", "onServiceConnected");

    super.onServiceConnected();
    new Exception().printStackTrace();

    AccessibilityServiceInfo info = new AccessibilityServiceInfo();
    info.flags = AccessibilityServiceInfo.DEFAULT;
    info.packageNames = null;
    info.eventTypes = AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED | AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED;
    info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC;
    setServiceInfo(info);

    String jsonString = "bla";
    Intent RTReturn = new Intent(PurchaseProActivity.RECEIVE_JSON);
    RTReturn.putExtra("json", jsonString);
    LocalBroadcastManager.getInstance(this).sendBroadcast(RTReturn);
}

In my activity I am receiving the broadcast and open a toast with the fetched string. On the Nexus 5 emulator all is working fine, but on my Sony Xperia 5 Compact it does not work. onServiceConnect never seems to be fired when I enable the service in the Accessibility settings.

I tried other apps which work similar (USSDNot for example) on the very same phone and they are able to capture popup texts via Accessibility API.

What am I doing wrong?

Community
  • 1
  • 1
Alex
  • 32,506
  • 16
  • 106
  • 171
  • 1
    basically SOLVED -- it just started working now, without me consciously changing anything concerning the accessibility service?! I leave it open, because somebody might have an idea, what happend. – Alex Oct 14 '16 at 12:53

0 Answers0