First of all, we will need to add relevant dependencies so we that can load the Twitter4J library. To do this, as usual, add the following entries to app/build.gradle:
compile 'org.twitter4j:twitter4j-core:4.0.6'compile 'org.twitter4j:twitter4j-stream:4.0.6'
The first line is a general interface to the Twitter API (to make status updates, for example) that contains the core domain objects, such as Status or User.
The following line adds support for streaming the Twitter API through TwitterStream, which allows you to constantly listen for the status updates without making multiple connections to Twitter: