Search code examples
androidtwitter4j

twitter4j - how to get User data from a screen name


I'm building an app for twitter on Android based on twitter4j.

I'm didn't find a way to get the "User" data for a specific screename,

If in a post, you have "blabla.... @toto..", I click on toto to show his profile.

I didn't find a way to get this info.

I have wrote an app based on fragement and Handler.

I plan to reuse the profile fragment I have wrote and I just have to send a message to make it works:

message = Message.obtain();
message.what = Constant.PROFILE ;
message.obj = UserMention ;
mHandler.sendMessage(message) ;

If I put the right data in "UserMention", it will show a fragment with the data displayed but I do not know who to file it...

Current what is done is :

long i= mTwitter.twitterObj.getId();
mUserProfile = mTwitter.twitterObj.showUser(i);

it will gave me the user info which mine if I'm the connected user.

Any idea ? I want to do the same but with a given screenname


Solution

  • This is from twitter 4.0.4 in examples folder: Here they have used User show using screen name in example ShowUser.java. You can try it.

    Twitter twitter = new TwitterFactory().getInstance();
    User user = twitter.showUser("screename");