在Android中获取Twitter粉丝列表

时间:2014-03-12 06:46:50

标签: android twitter twitter4j

我正在尝试使用以下代码获取Android中所有关注者的列表。

final long lCursor = -1;

new Thread(new Runnable() 
{           
@Override
public void run() 
{ 

try{
IDs followersIDs = twitter.getFollowersIDs(UserID, lCursor);
do {
for (long i : followersIDs.getIDs()){
Log.d("follower ID #", String.valueOf(i));
}
}while(followersIDs.hasNext());
} catch (TwitterException e) {
Log.i("fetchFollowers", e.getErrorMessage());
}

}).start();

但获得空指针异常

1 个答案:

答案 0 :(得分:0)

    IDs followersIds;     
    long lCursor = -1;
    do {
        followersIds=twitter.getFollowersIDs(TwaccessToken.getUserId(), lCursor);
       }while ((lCursor = followersIds.getNextCursor()) != 0);


   do
    {
  for (long i : followersIds.getIDs())
   {   
   contactid .add(twitter.showUser(i).getId()+"");
   nameList.add( twitter.showUser(i).getName());
   profileimageUrl.add(twitter.showUser(i).getProfileImageURL());
   }
   }while(followersIds.hasNext());