UseAndroid's lifecycle+ rxlifecycle-android-lifecycle to generate providers. Write the implementation yourself. If you use rxlifecycle-components, just extend the appropriate class, then use the built-inbindToLifecycle()(orbindUntilEvent()) methods: ...
createActivityLifecycleProvider(this); @Override public void onResume() { super.onResume(); myObservable .compose(provider.bindToLifecycle()) .subscribe(); } }If you use rxlifecycle-android-lifecycle, then you just pass your LifecycleOwner to AndroidLifecycle to generate a provider:...
bindUntilActivityEvent(lifecycle, ActivityEvent.DESTROY)) .subscribe(); Alternatively, you can let RxLifecycle determine the appropriate time to end the sequence: myObservable .compose(RxLifecycle.bindActivity(lifecycle)) .subscribe(); It assumes you want to end the sequence in the opposing lifecycle...
RxLifecycle The utilities provided here allow for automatic completion of sequences based on Activity or Fragment lifecycle events. This capability is useful in Android, where incomplete subscriptions can cause memory leaks. Usage You must provide an Observable<ActivityEvent> or Observable<FragmentEvent>...