Last active
March 2, 2018 17:07
-
-
Save gbzarelli/0f5a14a03f6b354f7fb6096b16a64ada to your computer and use it in GitHub Desktop.
Verificação do modo avião
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[...] | |
fun isAirplaneModeEnabled():Boolean{ | |
return Settings.Global.getInt(contentResolver, Settings.Global.AIRPLANE_MODE_ON, 0) != 0 | |
} | |
[...] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<receiver android:name=".receivers.AirPlaneIntentReceiver"> | |
<intent-filter> | |
<action android:name="android.intent.action.AIRPLANE_MODE" /> | |
</intent-filter> | |
</receiver> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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