Program Resource

Resource libraries for programmers and developers

Simple code to get specified user’s tweet in Android, v1.1 support.
API has restriction, where tweet data can be fetched up to 15 times per 15 min from same IP.


Twitter4j library is used; download from site below and copy required jar file to your libs folder in project.


Next, you need to get a access key.

Login, “Create a new application” and go to OAuth Settings to get your key.

Copy paste your 4 keys to code, and you are done.

public void init_fetch_tweet(String tweet_user_id,int tweet_num) {

	try {
   		String strConsumerKey = "*********";
   		String strConsumerSecret = "*********";
   		String strAccessToken = "*********";
   		String strAccessTokenSecret = "*********";

   		ConfigurationBuilder confbuilder  = new ConfigurationBuilder();

   		Twitter twitter = new TwitterFactory(;
   		List<Status> statuses = twitter.getUserTimeline(tweet_user_id,new Paging(1,tweet_num));
   		int count=0;
   		Collections.reverse(statuses); //reverse order
   		for (Status status : statuses){
       		String tweettext = status.getUser().getName()+&quot;:&quot;+status.getText()+&quot;\n (&quot;+status.getCreatedAt().toLocaleString()+&quot;)&quot;;
       		//now single tweet is in tweettext
	catch(Exception ex){
		//failed to fetch tweet
Print Friendly, PDF & Email

This post is also available in: Japanese

Leave a Reply

Your email address will not be published. Required fields are marked *