O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Filtering tweets

The way Twitter's search function works, we can end up having tweets in the stream that have no words that we were monitoring for. We can solve this problem by adding some additional filtering based on the text and the keywords that we are following.

There are a few ways to do that but, for the sake of the exercise, we will make use of a way that doesn't involve for loops and if statements. This approach might come in handy for other problems that might require a reactive way to solve them.

First of all, let's extract the monitored keywords to a separate variable--trackingKeywords:

final String[] trackingKeywords = {"Yahoo", "Google", "Microsoft"};final FilterQuery filterQuery = new FilterQuery() .track(trackingKeywords) ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required