VKRequest request = VKApi.users().get(VKParameters.from(VKApiConst.FIELDS, FIELDS));
request.executeWithListener(new VKRequest.VKRequestListener() {
@Override
public void onComplete(VKResponse response) {
VKApiUser user = ((VKList<VKApiUser>) response.parsedModel).get(0);
String urlImage = user.photo_max;
VKApiPhoto photo = new VKApiPhoto();
attachments = new VKAttachments();
photo.photo_604 = urlImage;
attachments.add(photo);
Log.i("VK", " "+urlImage);
}
});
VKParameters.from(VKApiConst.OWNER_ID, -546456,
VKApiConst.ATTACHMENTS, attachments,
VKApiConst.MESSAGE, message);
PhotoUpload serverResponse = vk.photos().getWallUploadServer(actor).execute();
WallUploadResponse uploadResponse = vk.upload().photoWall(serverResponse.getUploadUrl(), file).execute();
List<Photo> photoList = vk.photos().saveWallPhoto(actor, uploadResponse.getPhoto())
.server(uploadResponse.getServer())
.hash(uploadResponse.getHash())
.execute();
Photo photo = photoList.get(0);
String attachId = "photo" + photo.getOwnerId() + "_" + photo.getId();
GetResponse getResponse = vk.wall().post(actor)
.attachments(attachId)
.execute();