Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start AccessibilityService?

I'm trying to start my implementation of AccessibilityService by using

Intent mailAccessabilityIntent = new Intent(this, EmailAccessabilityService.class);
startService(mailAccessabilityIntent);

My problem is onServiceConnected() never been called. How do i start this service properly?

like image 566
eyal Avatar asked Feb 16 '12 14:02

eyal


People also ask

How do I start Accessibilityservice on Android?

Once your service is created and is correctly listed in the manifest file with the accessibility intent filter. Then yours service will appear under settings-accessibility-services. You start it by clicking on it then toggling it on.

How do I use Accessibilityservice?

Go to Settings > Accessibility. The Global Action Bar Service is installed on your device. The accessibility service requests permission to observe user actions, retrieve window content, and perform gestures on behalf of the user! When using a third party accessibility service, make sure you really trust the source!

How do I enable Accessibility service?

To access the Accessibility features on your Android device open the Settings app . In the Settings app, select Accessibility from the list. On the Accessibility screen, scroll down to the Interaction controls section and select Accessibility Menu. On the next screen, set the toggle switch for Accessibility Menu to On.

How do I turn off Accessibility services on Android?

Open your Android device's Settings app . Select Accessibility. Switch Access. At the top, select the On/Off switch.


2 Answers

Because accessibility services are able to explore and interact with on-screen content, a user has to explicitly enable services in Settings > Accessibility. Once a service is enabled, the system will start it automatically and bind it to the accessibility APIs.

Make sure you declare your service in your application manifest:

<service android:name=".MyAccessibilityService"
         android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE">
     <intent-filter>
         <action android:name="android.accessibilityservice.AccessibilityService" />
     </intent-filter>
     . . .
 </service>

You'll also need to provide configuration for your service, either by overriding setServiceInfo(AccessibilityServiceInfo) or adding a meta-data attribute and XML config file.

The meta-data attribute goes in your <service> declaration after the <intent-filter> tag and looks like this:

<meta-data android:name="android.accessibilityservice"
           android:resource="@xml/accessibilityservice" />

The XML config that you're referencing (in this case, accessibilityservice.xml) looks like this:

<accessibility-service
    android:accessibilityEventTypes="typeViewClicked|typeViewFocused"
    android:packageNames="foo.bar, foo.baz"
    android:accessibilityFeedbackType="feedbackSpoken"
    android:notificationTimeout="100"
    android:accessibilityFlags="flagDefault"
    android:settingsActivity="foo.bar.TestBackActivity"
    android:canRetrieveWindowContent="true"
    . . .
/>

There's more information on which tags you can use at http://developer.android.com/reference/android/R.styleable.html#AccessibilityService

like image 134
alanv Avatar answered Sep 21 '22 15:09

alanv


I've just done this today. Once your service is created and is correctly listed in the manifest file with the accessibility intent filter. Then yours service will appear under settings-accessibility-services. You start it by clicking on it then toggling it on. I don't know how to start it via intents yet if its even possible. I think its Lee GPS you can only navigate users to start button.

like image 39
JonWillis Avatar answered Sep 22 '22 15:09

JonWillis