Introducing ReactiveAirplaneMode
I’m continuing Rxfication of the Android. Recently I released brand new library called ReactiveAirplaneMode. As you may guess, it allows listening Airplane mode on Android device with RxJava observables. A usual I’ve hidden all implementation details, BroadcastReceivers and rest of the Android related stuff behind RxJava abstraction layer, so API is really simple. Just take a look on that:
1 | ReactiveAirplaneMode.create() |
In the code above subscriber will be notified only when airplane mode changes. If you want to read airplane mode and then listen to it, you can use the following method:
1 | ReactiveAirplaneMode.create() |
If you want to check airplane mode only once,
you can use get(context)
method, which returns Single<Boolean>
value:
1 | ReactiveAirplaneMode.create() |
If you want to check airplane mode only once without using Reactive Streams, just call isAirplaneModeOn(context)
method:
1 | boolean isOn = ReactiveAirplaneMode.create().isAirplaneModeOn(context); |
You can add this library to your project via Gradle:
1 | dependencies { |
If you want to know more details, see sample app, documentation & tests, check repository with the source code at: https://github.com/pwittchen/ReactiveAirplaneMode.