Fetching all tweets using twitter4j around a given location
<p>I want to fetch all the tweets from twitter API using Twitter4j. Here is my code to fetch tweets using <code>geoCode</code> but I am unable to fetch all tweets, it is just showing me around 100 tweets. Is there any way I can fetch them all. I think there is a rate limit on the amount of tweets i can receive but i am not sure.
Could anyone help ?</p>

<pre><code>import java.util.List;

import twitter4j.*;
import twitter4j.auth.AccessToken;

public class Main {
public static void main(String[] args) {

    final Twitter twitter = new TwitterFactory().getInstance();
    final  AccessToken accessToken = new AccessToken("XXX", "YYY");
    twitter.setOAuthConsumer("AAA", "BBB");
    twitter.setOAuthAccessToken(accessToken);

    try {
        Query query = new Query();
        query.geoCode(new GeoLocation(37.781157,-122.398720),1000.0,"mi");
        QueryResult result;
        System.out.println("Searching...");
        int Count=0;

        do {
            result = twitter.search(query);
            List&lt;Status&gt; tweets = result.getTweets();
            for (Status tweet : tweets) {
                if(tweet.getGeoLocation()!=null)
                    System.out.println(tweet.getGeoLocation());
            }
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        while ((query = result.nextQuery()) != null);
        System.out.println(Count);
        System.exit(0);
    } catch (TwitterException te) {
        te.printStackTrace();
        System.out.println("Failed to search tweets: " + te.getMessage());
        System.exit(-1);
    }
}
</code></pre>

<p>}</p>