Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get a user's avatar VK SDK

Good day. The question on the use of library VK. How to get a profile picture, using VKSDK\ Can not find the right information on the Internet.

        

like image 732
user3366290 Avatar asked Feb 13 '23 20:02

user3366290


1 Answers

In your request you need to specify one of the following fields: photo_50 or photo_100 or photo_200:

VKRequest yourRequest = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS,"photo_50"))

After that when you will retrieve users data you can get photo_50:

yourRequest.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
    super.onComplete(response);

    VKUsersArray usersArray = (VKUsersArray) response.parsedModel;

    for (VKApiUserFull userFull : usersArray) {
          Log.i(TAG, "Avatar image URL: " + userFull.photo_50);            
        }
    }
}
like image 109
user3760402 Avatar answered Feb 15 '23 11:02

user3760402