I am trying to programmatically on/off the airplane mode in android, I rooted my device even install app as a system app but still troubling to achieve. below is my code
public void toggleAirplaneMode(int value, boolean state) {
Settings.Global.putInt(getContentResolver(),
Settings.Global.AIRPLANE_MODE_ON, value);
// broadcast an intent to inform
Intent intent = new Intent(Intent.ACTION_AIRPLANE_MODE_CHANGED);
intent.putExtra("state", !state);
sendBroadcast(intent);
}
calling the function by for turn off the airplane mode
toggleAirplaneMode(0,true);
calling the function by for turn on the airplane mode toggleAirplaneMode(1,false);
it's throw exception permission denial: writing to secure settings requires android.permission.write_secure_settings
I Already rooted the device and installed the app as a system app in my manifest permissions
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
Help me to solve this issue.