Hello everyone, I am trying to retrieve tweets and display them on a google maps(on a android phone) I am using Twitter4j api to retrieve tweets and display them on Google maps in a android phone.
I am using two classes one for retrieving tweets with the help of twitter4j storing coordinates of tweets in a array and pass them to second class to display them on map, but this solution does not works for me My both classes are as below class to display tweets on map package com.example.hellomap; import java.util.ArrayList; import java.util.Date; import twitter4j.FilterQuery; import twitter4j.GeoLocation; import twitter4j.GeoQuery; import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.StallWarning; import twitter4j.Status; import twitter4j.StatusDeletionNotice; import twitter4j.StatusListener; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.TwitterStream; import twitter4j.TwitterStreamFactory; import twitter4j.User; import twitter4j.conf.ConfigurationBuilder; import android.location.Criteria; import android.location.LocationManager; import android.os.Bundle; import android.support.v4.app.FragmentActivity; import com.google.android.gms.maps.GoogleMap; import com.google.android.gms.maps.SupportMapFragment; import com.google.android.gms.maps.model.LatLng; import com.google.android.gms.maps.model.MarkerOptions; public class MainActivity extends FragmentActivity { private GoogleMap mMap; GeoLocation loc=null; double[][] locCoordinates =null; NumberOfTweets NOT=new NumberOfTweets(); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); setUpMapIfNeeded(); } @Override protected void onResume() { super.onResume(); setUpMapIfNeeded(); locCoordinates = NOT.ab(); } private void setUpMapIfNeeded() { if (mMap == null) { mMap = ((SupportMapFragment) getSupportFragmentManager() .findFragmentById(R.id.map)).getMap(); } if (mMap == null) { return; } // Initialize map options. For example: //mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID); for(int i=0;i<locCoordinates.length;i++){ } } } while class to retrieve tweets is as below package com.example.hellomap; import java.util.ArrayList; import java.util.Date; import twitter4j.FilterQuery; import twitter4j.GeoLocation; import twitter4j.GeoQuery; import twitter4j.Query; import twitter4j.QueryResult; import twitter4j.StallWarning; import twitter4j.Status; import twitter4j.StatusDeletionNotice; import twitter4j.StatusListener; import twitter4j.Twitter; import twitter4j.TwitterException; import twitter4j.TwitterFactory; import twitter4j.TwitterStream; import twitter4j.TwitterStreamFactory; import twitter4j.User; import twitter4j.conf.ConfigurationBuilder; //http://forum.processing.org/topic/geolocation-twitter-search-twitter4j public class NumberOfTweets { GeoLocation location = null; double[][] locCoordinates = null; NumberOfTweets NOT=new NumberOfTweets(); public double[][] TweetGathering() throws TwitterException { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.setDebugEnabled(true); cb.setOAuthConsumerKey("TTg7JSLqUinlfkWgFZg"); cb.setOAuthConsumerSecret("dHDO2VmPCMyf637uSfgi4rLUyHYYuNSPIFo1Sbe2o"); cb.setOAuthAccessToken("35448069-nUY9WeWmgvmBNPVM353ejxSbZRHPBGHzHTGwV9nc"); cb.setOAuthAccessTokenSecret("mcZpdmB95yWt2rVWs1Dw5hAafOrWZX0XsZmiSH90H8"); Twitter twitter = new TwitterFactory(cb.build()).getInstance(); double lat = 60.1833; double lon = 24.8333; double latitude; double longitude; int xLat = 3; int yLon = 2; int totalResults = 3; GeoLocation Loc = new GeoLocation(lat, lon); locCoordinates = new double[xLat][yLon]; String queryStr = ""; // create query object try { Query query = new Query(queryStr); // initialize the query object // and pass in the query string query.geoCode(Loc, 2, "mi"); query.setCount(totalResults); // set number of results (100 max) // send query object to the Twitter API QueryResult result = twitter.search(query); ArrayList resultTweets = (ArrayList) result.getTweets(); Status tweet = null; for (int i = 0; i < resultTweets.size(); i++) { tweet = (Status) resultTweets.get(i); User user = tweet.getUser(); location = tweet.getGeoLocation(); for (int j = 0; j < 3; j++) { int k = 0; locCoordinates[j][k] = location.getLatitude(); k = 1; locCoordinates[j][k] = location.getLongitude(); } } } catch (TwitterException e) { System.out.println("Search tweets: " + e); } return locCoordinates; } public double[][] ab() { try { NOT.TweetGathering(); } catch (TwitterException e) { // TODO Auto-generated catch block e.printStackTrace(); } return locCoordinates; } } Please any help would be highly appreciated, Thanks BR -- You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-maps-js-api-v3+unsubscr...@googlegroups.com. To post to this group, send email to google-maps-js-api-v3@googlegroups.com. Visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en. For more options, visit https://groups.google.com/groups/opt_out.