Android Tutorial Programmatically Setting AIRPLANE_MODE_ON and Off

how can you catch the sense version?
Then I could disable the function in my app.
 
Airplane Mode on off

Since JellyBean 4.2

We can only Read the AirplaneMode

Here ist the Link

Android 4.2 APIs | Android Developers

We need Edit the manifest

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


We can Write with this

// To Write
Settings.Global.putString(getContentResolver(), "airplane_mode_on", "1");

// To Read
String result = Settings.Global.getString(getContentResolver(), Settings.Global.AIRPLANE_MODE_ON);


My Question.
How ist he Code for Write (i am a Beginner)

Settings.Global.putString(getContentResolver(), "airplane_mode_on", "1");


can i have some help?
 
I think we can write over this

Settings.Global.putString(getContentResolver(), "airplane_mode_on", "1");
 
I am getting a access denied error- but i have this manifest edited!
 
I added it under the first orange(or red) line

edit: why permissions? isn't it only 1?
 
The Error is still here.
And now i have this lines in Manifest and i removed the red code before.
your code is blue
 
Hi,

I have this problem
Code:
java.lang.SecurityException: Permission Denial: not allowed to send broadcast android.intent.action.AIRPLANE_MODE from pid=3177, uid=10193

in manifest editor
Code:
AddPermission(android.permission.WRITE_SETTINGS)
AddPermission(android.permission.WRITE_SECURE_SETTINGS)

how can I solve?
 
I got an error. java.lang.security.exception permission denial not allowed to send broadcast android.intent.action Airplane_mode from pid=14318 uid = 10060 here's what i added to the manifest

AddPermission(android.permission.READ_PHONE_STATE)
AddPermission(android.permission.WRITE_SETTINGS) added this
AddManifestText(
 
Last edited:
Back
Top