public void updateTwitterStream(Location location, int radius) { Log.d(TAG, "updateTwitterStream()"); double[][] mapRegion = GeoCalculationsHelper.getMapRegion(location, radius); FilterQuery filterQuery = new FilterQuery(); filterQuery.locations(mapRegion); twitterStream.filter(filterQuery); }
public static void streamTweets(String keywords, String location, Boolean hideRetweets) throws URLs.ConnectionException, URLs.HTTPQueryException, GeolocationSearch.NoKeyException, GeolocationSearch.SearchLocationException, MalformedURLException { twitter4j.TwitterStream twitterStream = new TwitterStreamFactory().getInstance(); twitterStream.addListener( new StatusAdapter() { public void onStatus(Status status) { if (!(status.isRetweet() && hideRetweets)) { printTweet(status, true); } } }); Double[] coordinates = getCoordinatesByQuery(location); double[][] doubleCoordinates = { {coordinates[1] - RADIUS, coordinates[0] - RADIUS}, {coordinates[1] + RADIUS, coordinates[0] + RADIUS} }; String[] arrayKeywords = {keywords}; FilterQuery fq = new FilterQuery(); fq.locations(doubleCoordinates); fq.track(arrayKeywords); twitterStream.filter(fq); }