Skip to content

Instantly share code, notes, and snippets.

@gbzarelli
Last active March 2, 2018 17:07
Show Gist options
  • Save gbzarelli/0f5a14a03f6b354f7fb6096b16a64ada to your computer and use it in GitHub Desktop.
Save gbzarelli/0f5a14a03f6b354f7fb6096b16a64ada to your computer and use it in GitHub Desktop.
Verificação do modo avião
[...]
fun isAirplaneModeEnabled():Boolean{
return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0
}
[...]
<receiver android:name=".receivers.AirPlaneIntentReceiver">
<intent-filter>
<action android:name="android.intent.action.AIRPLANE_MODE" />
</intent-filter>
</receiver>
class AirPlaneIntentReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val isAirplaneModeOn = intent.getBooleanExtra("state", false)
if (isAirplaneModeOn) {
//TODO - ENABLED
} else {
//TODO - DISABLED
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment