I have to disable AIRPLANE MODE
and DATE TIME SETTINGS
in my app, for that i used these intent filters but none
of them works
for me
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.settings.AIRPLANE_MODE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.settings.DATE_SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
But earlier i successfully disabled Settings
by using below intent-filter
<intent-filter >
<action android:name="android.settings.SETTINGS" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
TLDR: Don't do that.
Think what happens if user couldn't enable airplane mode though if they want/should.
Important system settings cannot allowed to change from your app.
I recommend:
EDIT: it looks like this:
here's some point.
Build.VERSION.SDK_INT
to useSettings.Global
for newer devices. Airplane mode is moved to here.startActivity(new Intent(Settings.ACTION_AIRPLANE_MODE_SETTINGS));
As for version 4.2 and up you are not able to control the Airplane mode programmatically.
You are able to do so only if the user has a rooted device.
As written in the API DOC:
"Some device settings defined by Settings.System are now
read-only
. If your app attempts to write changes to settings defined in Settings.System that have moved toSettings.Global
, the write operation will silently fail when running onAndroid 4.2
and higher. Even if your value forandroid:targetSdkVersion
andandroid:minSdkVersion
is lower than17
, your app is not able to modify the settings that have moved toSettings.Global
when running onAndroid 4.2
and higher."