in sample/src/main/java/autodispose2/sample/JavaActivity.java [74:93]
protected void onResume() {
super.onResume();
Log.d(TAG, "onResume()");
// Using automatic disposal, this should determine that the correct time to
// dispose is onPause (the opposite of onResume).
Observable.interval(1, TimeUnit.SECONDS)
.doOnDispose(() -> Log.i(TAG, "Disposing subscription from onResume()"))
.to(autoDisposable(AndroidLifecycleScopeProvider.from(this)))
.subscribe(num -> Log.i(TAG, "Started in onResume(), running until in onPause(): " + num));
// Setting a specific untilEvent, this should dispose in onDestroy.
Observable.interval(1, TimeUnit.SECONDS)
.doOnDispose(
() -> Log.i(TAG, "Disposing subscription from onResume() with untilEvent ON_DESTROY"))
.to(autoDisposable(AndroidLifecycleScopeProvider.from(this, Lifecycle.Event.ON_DESTROY)))
.subscribe(
num -> Log.i(TAG, "Started in onResume(), running until in onDestroy(): " + num));
}