I am writing an app that requires ACCESSIBILITY SERVICE PERMISSION. So, I have the following code that brings up ACCESSIBILITY intent as soon as the app is started. Under ACCESSIBILITY intent -> Installed Apps, I noticed my app is not listed. How come and how do I get my app listed under ACCESSIBILITY installed apps. So, I can enable ACCESSIBILTY PERMISSION for my app.
Here is the permission in AndroidManifest.xml:
<uses-permission android:name="android.permission.BIND_ACCESSIBILITY_SERVICE"/>
Here is the code in the MainActivity.kt
if (!isAccessibilityServiceEnable(applicationContext)) {
val accessibleIntent = Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS)
startActivity(accessibleIntent)
}
private fun isAccessibilityServiceEnable(context: Context): Boolean {
val accessibilityManager = (context.getSystemService(ACCESSIBILITY_SERVICE) as AccessibilityManager)
val accessibilityServices = accessibilityManager.getEnabledAccessibilityServiceList(AccessibilityServiceInfo.FEEDBACK_ALL_MASK)
for (info in accessibilityServices) {
if (info.id.contains(context.packageName)) {
return true
}
}
return false
}
Here is the image of the Intent Have a look at the red arrow:
From what I can tell in the accessibility service documentation, you need that permission in the service, not as a standalone uses-permission
:
<application>
<service android:name=".MyAccessibilityService"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE"
android:label="@string/accessibility_service_label">
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>