Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically enabling/disabling accessibility settings on Android device

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

like image 475
John Weidner Avatar asked Jul 13 '16 19:07

John Weidner


People also ask

How do I fix Android Accessibility settings to turn off automatically?

On your device, open Settings > Accessibility. Scroll until you find Accountable2You. Tap on Accountable2You. Toggle Accessibility to Off and then On again (it may show as on but still be disabled - this step will reset it).

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.

How do I enable Accessibility services on Android?

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.


Video Answer


1 Answers

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);
like image 193
abhishesh Avatar answered Sep 18 '22 17:09

abhishesh