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.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With