First of all, let's set up the library so that it can be used in the code. Again, this is a very straightforward thing to do. Just add the following lines to the app/build.gradle file:
compile 'com.trello.rxlifecycle2:rxlifecycle:2.0.1'
compile 'com.trello.rxlifecycle2:rxlifecycle-android:2.0.1'
compile 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1'
The first line adds support for general lifecycle management:
compile 'com.trello.rxlifecycle2:rxlifecycle:2.0.1'
It means that this library can be used not only for Android. The following line adds the necessary support for Android Platform:
compile 'com.trello.rxlifecycle2:rxlifecycle-android:2.0.1'
This line includes custom Activities for subclassing for even easier access to lifecycle management:
compile 'com.trello.rxlifecycle2:rxlifecycle-components:2.0.1'