Android Tutorial Programmatically Setting AIRPLANE_MODE_ON and Off

D

Deleted member 103

Guest
how can you catch the sense version?
Then I could disable the function in my app.
 

Bardill

Member
Licensed User
Longtime User
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?
 

Bardill

Member
Licensed User
Longtime User
I think we can write over this

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

chrjak

Active Member
Licensed User
Longtime User
I am getting a access denied error- but i have this manifest edited!
 

chrjak

Active Member
Licensed User
Longtime User
I added it under the first orange(or red) line

edit: why permissions? isn't it only 1?
 

chrjak

Active Member
Licensed User
Longtime User
The Error is still here.
And now i have this lines in Manifest and i removed the red code before.
your code is blue
 

FabioG

Active Member
Licensed User
Longtime User
Hi,

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

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

how can I solve?
 

shb777

Active Member
Licensed User
Longtime User
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(
 

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Top