Created
October 26, 2018 09:22
-
-
Save eugenebrusov/8ec243835474685934c3916ece7ab7f1 to your computer and use it in GitHub Desktop.
Exception on broadcast unregister
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
Flowable | |
.create<Boolean>({ emitter -> | |
val broadcastReceiver = object : BroadcastReceiver() { | |
override fun onReceive(context: Context?, intent: Intent?) { | |
try { | |
throw RuntimeException("Test exception") | |
} catch(e: Throwable) { | |
emitter.tryOnError(e) | |
} | |
} | |
} | |
try { | |
application.registerReceiver(broadcastReceiver, IntentFilter(LocationManager.PROVIDERS_CHANGED_ACTION)) | |
emitter.setCancellable { | |
throw RuntimeException("unregisterReceiver exception") | |
application.unregisterReceiver(broadcastReceiver) | |
} | |
} catch (e: Throwable) { | |
emitter.tryOnError(e) | |
} | |
}, BackpressureStrategy.MISSING) | |
.onErrorReturn { false } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment