in sample/src/main/java/autodispose2/sample/JavaActivity.java [39:57]
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.d(TAG, "onCreate()");
setContentView(R.layout.activity_main);
// Using automatic disposal, this should determine that the correct time to
// dispose is onDestroy (the opposite of onCreate).
Observable.interval(1, TimeUnit.SECONDS)
.doOnDispose(() -> Log.i(TAG, "Disposing subscription from onCreate()"))
.to(autoDisposable(AndroidLifecycleScopeProvider.from(this)))
.subscribe(num -> Log.i(TAG, "Started in onCreate(), running until onDestroy(): " + num));
getSupportFragmentManager()
.beginTransaction()
.add(R.id.fragment_container, new JavaFragment())
.commitNow();
}