Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Enable Accessibility Setting for my application as soon as the application is launched

I am trying to enable Accessibility setting for my application as soon as the application is launched. But I am not able to do it currently. I have used the following code:

 Settings.Secure.putString(getContentResolver(), 
                           Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, 
                           "package_name");
 Settings.Secure.putString(getContentResolver(), 
                           Settings.Secure.ACCESSIBILITY_ENABLED, 
                           "1");

To use this code snippet we have to declare the following permission:

WRITE_SECURE_SETTINGS, but this permission is applicable only for system applications. How can I achieve the same functionality for my application. All suggestions are welcome.

like image 833
keshav kowshik Avatar asked Dec 08 '25 18:12

keshav kowshik


1 Answers

The API says: Settings.Secure are

for preferences that the user must explicitly modify through the system UI or specialized APIs for those values, not modified directly by applications.

If you want to check programmatically to prompt the user, see also android-how-do-you-check-if-a-particular-accessibilityservice-is-enabled. The code to call the intent is given for example in how-to-programmatically-enable-disable-accessibility-service-in-android, it is

Intent intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
startActivityForResult(intent, 0);
like image 57
serv-inc Avatar answered Dec 11 '25 23:12

serv-inc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!