Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9192029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:49:47+00:00 2026-06-17T20:49:47+00:00

I am using the Twitter4J Library and I am trying to implement some Async

  • 0

I am using the Twitter4J Library and I am trying to implement some Async Tasks to make some calls to the service as follows.

public class TweetsActivity extends Activity {


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_post_tweet);
    new getFollowers().execute();

}
@SuppressWarnings("unused")
private class getFollowers extends AsyncTask<String,Void,List<String>>
{

    @Override
    protected List<String> doInBackground(String... arg0) {
        List<String> friends = null;
        Twitter t = ((TwitterApplication)getApplication()).getTwitter();
        try {
            IDs names  = t.getFollowersIDs("jd_biggestboss");
            for(int i:names.getIDs())
            {
                friends.add(t.showUser(i).getScreenName());

            }
            return friends;
        } catch (TwitterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }// TODO Auto-generated method stub
        return null;
    }

    protected void onPostExecute(List<String> result) {
        for(String name:result)
            System.out.println(name);

     }

}

}

I am getting an error.This is the stack trace. I checked to ensure that I was not accessing any UI elements from my UI thread and so on. So what could be causing the problem? Could it be that each call that I make to the API needs to be in a separate Async task? Thanks in advance.

01-27 02:22:58.042: W/dalvikvm(30528): threadid=11: thread exiting with uncaught exception (group=0x40ab0a08)
01-27 02:22:58.052: E/AndroidRuntime(30528): FATAL EXCEPTION: AsyncTask #1
01-27 02:22:58.052: E/AndroidRuntime(30528): java.lang.RuntimeException: An error occured while executing doInBackground()
01-27 02:22:58.052: E/AndroidRuntime(30528):    at android.os.AsyncTask$3.done(AsyncTask.java:278)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.FutureTask.run(FutureTask.java:137)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.lang.Thread.run(Thread.java:864)
01-27 02:22:58.052: E/AndroidRuntime(30528): Caused by: java.lang.NullPointerException
01-27 02:22:58.052: E/AndroidRuntime(30528):    at com.tmm.android.twitter.TweetsActivity$getFollowers.doInBackground(TweetsActivity.java:40)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at com.tmm.android.twitter.TweetsActivity$getFollowers.doInBackground(TweetsActivity.java:1)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at android.os.AsyncTask$2.call(AsyncTask.java:264)
01-27 02:22:58.052: E/AndroidRuntime(30528):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
01-27 02:22:58.052: E/AndroidRuntime(30528):    ... 5 more
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:49:48+00:00Added an answer on June 17, 2026 at 8:49 pm

    you will need to initialize the friends ArrayList before adding elements to it inside doInBackground method :

    List<String> friends = new ArrayList<String>();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the twitter-async library to do some oauth calls to twitter but ultimately,
I'm using the twitter4j library to access the public twitter stream. I'm trying to
I am using the twitter4j library to collect some data in twitter. There is
I am trying to integrate twitter api using library twitter4j-core-2.1.1-SNAPSHOT.jar. But i am getting
I am trying to upload and share image using twitter4j library but unable to
i'm trying make simple app twitter and i use twitter4j library and i got
I'm trying to login on twitter from my android app using Twitter4j library but
I'm calling the twitter4j library using Clojure like so: (def twitter (. (TwitterFactory.) getInstance))
I am trying to build connectors to twitter on top of twitter4j using java.
I'm using twitter-async library to interact with twitter api. However, the memory limit keeps

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.