Android get user profile image


hi ,
i want to get user profile image using fabric api in android



Are you wanting to get the profile image of the logged in user? If so, you can get this by calling AccountServices#verifyCredentials(), which will return the user object associated with the specified TwitterSession.

However, if you want to get the profile image of any Twitter user, there isn’t a method out of the box that allows you to do this. You’ll need to extend the TwitterApiClient to add additional Twitter authenticated endpoints. Below is an example of how you can get a user’s profile image by using the /1.1/users/show.json endpoint.

First, extend the TwitterApiClient to provide a UsersService.

    class MyTwitterApiClient extends TwitterApiClient {
    public MyTwitterApiClient(TwitterSession session) {

    public UsersService getUsersService() {
        return getService(UsersService.class);

interface UsersService {
    void show(@Query("user_id") Long userId,
            @Query("screen_name") String screenName,
            @Query("include_entities") Boolean includeEntities,
            Callback<User> cb);

Next, get the UsersService and call its show method, passing in the defined query parameters. I defined the query parameters based on the ones that are documented here.

new MyTwitterApiClient(session).getUsersService().show(12L, null, true,
    new Callback<User>() {
        public void success(Result<User> result) {
            Log.d("twittercommunity", "user's profile url is "

        public void failure(TwitterException exception) {
            Log.d("twittercommunity", "exception is " + exception);

Hope this helps!

How can i get Profile image of logged in user

Hey @lientm delighted to hear there’s a way to do this!

Could you be more detailed in your answer please? I’m relatively new to developing and would love to implement this into my application.



I actually think @lientm has given a really detailed answer here - what specific part of the code is causing you confusion, so we can assist?

The final URL to the profile image will be logged by this method here:

    public void success(Result<User> result) {
        Log.d("twittercommunity", "user's profile url is "


hey @andypiper thanks for helping me, but I’m finding it hard to understand the code snippet above!
I am unsure in terms of what imports are needed, where in the in class it is located, and also the tag!
Basic items but I am pretty new to this.

Thanks :slight_smile:


Hi lientm

Do you have to get permission first (from Twitter, i.e. get app white listed) to access a user’s profile image as I’ve tried the code above, and I can’t access the image’s url. I am only interested in getting the profile image of the logged in user as you mentioned in your first paragraph. I have tried verifyCredentials(), but I can’t get that to work either, see code below. I’m sure I’m doing something obviously wrong.

                    .verifyCredentials(true, false, new Callback<User>() {

                        public void failure(TwitterException e) {


                        public void success(Result<User> userResult) {

                            User user =;
                            twitterImage = user.profileImageUrl;





You do not need any whitelisting to use this. In order to get the profile image though, you can’t rely on it being inside the verifyCredentials success callback, you need to define a new service with TwitterApiClient to hit the /1.1/users/show.json endpoint as described above.


I’m using Fabric API. Based on this link Twitter Fabric API get Profile Image of various sizes

How can i get the original image (the one with the largest size).

Right now, i’m fetching all the data through the user object

 User user =;
twitterImage = user.profileImageUrl;

However, it returns the default image with size 48x48.
I want this one Twitter profile image with largest size


Looking into the Android Twitter Kit code (which is open source on GitHub) it does look like it only grabs the “normal” image and not the original.


So, what’s the solution? How do i get the larger profile image?


You’d have to use the APIClient methods to call users/show.json and then retrieve the URL for the profile image, and modify the URL to point at the original. Then, retrieve that directly in code.


If you can show me some code please, because theoretically whatever you said is already mentioned in the docs, and i’ve already read that. But the manipulation of the URL is something that i don’t know how to do!


I am really keen to be able to get the highest resolution possible of the profile picture.
48x48 serves to nothing, unfortunately. Specially with Retina devices these days.

Can anyone please help?



Ok! It’s quite simple. Since i’m using Java, i just called .replace() method.

  twitterImage = user.profileImageUrl.replace("_normal", ""); --> this gives me the original image size.

There are 2 patterns for the URL.

  1. URL ends with _normal (before dot image extension) --> returns 48x48
  2. URL ends with _bigger (before dot image extension) —> returns 73x73

And if you want a bigger size than the above tow, then just remove the underscore and the corresponding text after that. Done !


Hi when i am using the above procedure , i am getting jack is user name and Profile pic as below

Please help me where it went wrong.

Update: It Got solved with verifyCredentials
.verifyCredentials(true, false, new Callback()

closed #17