Answer the question
In order to leave comments, you need to log in
VK API for Android: why does camera_b.gif or null come instead of photo_big?
Hello, in an android application, I'm trying to get the name, city and large photo of the user of this application:
private final static String FIELDS = "photo,city,sex";
//private final static String FIELDS = "photo_big,city,sex";
private VKCallback<VKAccessToken> mCallback = new VKCallback<VKAccessToken>() {
@Override
public void onResult(VKAccessToken res) {
VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS, FIELDS));
request.executeWithListener(mRequestListener);
}
};
private VKRequest.VKRequestListener mRequestListener = new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
try {
VKList<VKApiUserFull> list = (VKList<VKApiUserFull>) response.parsedModel;
VKApiUserFull user = list.get(0);
String sid = String.valueOf(user.id);
String given = user.first_name;
String family = user.last_name;
String photo = user.photo_200;
String place = (user.city != null ? user.city.title : "");
boolean female = (user.sex == VKApiUserFull.Sex.FEMALE);
// update UI
} catch (Exception e) {
}
}
};
@Override
public void onClick(View v) {
VKSdk.login(getActivity());
}
{"response":[
{"id":59751333,
"first_name":"Alexander",
"last_name":"Farber",
"sex":2,
"city":{"id":1945522,"title":"Bochum"},
"photo":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg"
}]}
public final static String FIELD_PHOTO_400_ORIGIN = "photo_400_orig";
public final static String FIELD_PHOTO_MAX = "photo_max";
public final static String FIELD_PHOTO_MAX_ORIGIN = "photo_max_orig";
public final static String FIELD_PHOTO_BIG = "photo_big";
Answer the question
In order to leave comments, you need to log in
Well, you don't ask them...
private final static String FIELDS = "photo, photo_50, photo_100, photo_200, city, sex";
Well, apparently the answer is: photo_50 , photo_100 , photo_200 can be obtained through the VkApiUserFull object.
The remaining (and larger) photos of the VK user will have to be retrieved via JSONObject: photo_400 , photo_max , photo_max_orig and (obsolete?) photo_big .
Here is an example of my info (id changed):
{"response":[{"id":59751333,
"first_name":"Alexander",
"last_name":"Farber",
"sex":2,
"city":{"id":1945522,"title":"Bochum"},
"photo":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg",
"photo_50":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e3\/n-yDMG4lvvk.jpg",
"photo_100":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e2\/Kt5-Wj2Ffv4.jpg",
"photo_200":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e1\/oJrjeeYO44I.jpg",
"photo_max":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e1\/oJrjeeYO44I.jpg",
"photo_big":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7df\/TnyKeffL_mU.jpg",
"photo_max_orig":"https:\/\/pp.vk.me\/c319319\/v319319333\/b7e0\/Zg6YbDQnqiM.jpg"
}]}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question