How can I programmatically enable/disable an android screen reader service such as TalkBack?
I am developing a kiosk type application that will be installed on an Android device that will be loaned to visitors while they visit a particular museum. (We are still in the process of determining what device we will use.) The plan is to only allow users to use our app and not have access to the android settings application. However, we'd like to allow users to configure some accessibility settings. When they are finished with the device, we need to restore all the settings to our defaults.
The discussion at the link below has many suggesting launching Android's Settings app. But we don't want users accessing many other settings.
How to Programmatically Enable/Disable Accessibility Service in Android
Only system apps can enable/disable accessibility service programatically. System apps can directly write in settings secure db to start accessibility service.
Settings.Secure.putString(getContentResolver(),Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, "com.packagename/com.packagename.componentname");
Following permission is required to write in settings secure db:
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
For non system apps, only way to start accessibility service is direct them to accessibility settings screen via intent and let user manually start the service :
Intent intent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS);