Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the Permission WRITE_SECURE_SETTINGS in android? [duplicate]

I am trying to enable the Accessibility Service Settings above 4.0 but It is showing an Exception i.e.,

Caused by: java.lang.SecurityException: Permission denial: writing to secure settings requires android.permission.WRITE_SECURE_SETTINGS

In Manifest I have Declared This permission like this.

<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />

But in manifest giving compilation Error i.e., Permission is only System Apps. So i am not Understanding how to resolve this issue.

Thanks in advance

Here is my sample code

if (Settings.Secure.getString(getContentResolver(),
                Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) {
            if (Settings.Secure.getString(getContentResolver(),
                    Settings.Secure.ACCESSIBILITY_ENABLED).contains("1")) {
                System.out.println("Putting the Value to Enable..");
                Settings.Secure.putInt(getContentResolver(),
                        Settings.Secure.ACCESSIBILITY_ENABLED, 0);
            } else {
                Settings.Secure.putInt(getContentResolver(),
                        Settings.Secure.TOUCH_EXPLORATION_ENABLED, 1);
            }
        }
like image 236
hareesh J Avatar asked Oct 23 '13 10:10

hareesh J


People also ask

What is Read_phone_state permission?

android. permission. READ_PHONE_STATE - You must ask the end user to grant this permission.) Allows read only access to the phone's state, and is used to determine the status of any ongoing calls. You need this permission so you can verify that your end user receives a phone call from Telesign.

What is signature level permission in android?

" signature " A permission that the system grants only if the requesting application is signed with the same certificate as the application that declared the permission. If the certificates match, the system automatically grants the permission without notifying the user or asking for the user's explicit approval.


1 Answers

WRITE_SECURE_SETTINGS is not available to applications. No app outside of the system/firmware can get that permisssion.

Please check this answer

like image 143
null pointer Avatar answered Sep 17 '22 08:09

null pointer