Accessibility service for my application does not work if I reinstall the application

The accessibility service is not tied to my application if I do not install the "Availability" option in the "Settings" → "Accessibility" section before uninstalling my application.

Note: In order to work again, I need to restart my phone.

Can someone suggest me how to safely reinstall my application without disabling accessibility service

+3
source share
1 answer

I was able to reinstall the service when it was turned on (and continue to receive events after that), after configuring the service settings.

I changed android: packageNames = "com.example.android.apis" (got this from tutorials) in android: packageNames = "@null"

Today, I have part of the xml configuration (for JB):

<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android" android:description="@string/accessibility_description" android:packageNames="@null" android:accessibilityEventTypes="typeNotificationStateChanged" android:accessibilityFlags="flagDefault" android:accessibilityFeedbackType="feedbackGeneric" android:notificationTimeout="100" android:canRetrieveWindowContent="false" /> 

and in the Java part (for pre-JB, in the onServiceConnected () service):

  AccessibilityServiceInfo info = new AccessibilityServiceInfo(); info.feedbackType = AccessibilityServiceInfo.FEEDBACK_GENERIC; info.eventTypes = AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED; info.notificationTimeout = 100; info.packageNames = null; info.feedbackType = AccessibilityServiceInfo.DEFAULT; this.setServiceInfo(info); 

I would like this to help in your own case ...

+1
source

Source: https://habr.com/ru/post/980442/


All Articles