Reputation: 524
How to open AccessibilityService by default in Android ? don't know how to do it .
<service
android:name=".NotificationFetcherService"
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/haotingmetadata" />
</service>
<accessibility-service xmlns:android="http://schemas.android.com/apk/res/android"
android:accessibilityEventTypes="typeNotificationStateChanged"
android:accessibilityFeedbackType="feedbackAllMask"
android:notificationTimeout="200" />
Upvotes: 2
Views: 2248
Reputation: 2669
AccessibilityServices can be headless (no UI), so if you mean how do you "start" the service, the short answer is: You can't.
They are not like other services in that the operating system controls them starting and stopping based on the settings the user has selected. The best you can do is launch the Accessibility settings page and get the user to enable it for you:
Intent goToSettings = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);
goToSettings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(goToSettings);
Upvotes: 6