Upd. I update it this answear because VK released official sdk https://vk.com/dev/android_sdk.
You should use it now for any purposes, it has documentation for all your needs too.
Ok, here's solution that perfectly works, I tried it myself:
Download Vkontakte SDK for Android: https://github.com/thest1/Android-VKontakte-SDK.
1) Upload an image to the server with function form here: https://github.com/devindi/Android-VKontakte-SDK/commit/342acbe76e97181fd1f09820504e47249c962640
/**
* Upload image to user wall. Method requires httpmime library to create POST with image
* you can download it here:http://hc.apache.org/downloads.cgi
* direct link: http://mirrors.besplatnyeprogrammy.ru/apache//httpcomponents/httpclient/binary/httpcomponents-client-4.2.3-bin.zip
* @param filePath absolutely path to image
* @param userID
* @return uploaded photo data (photo id and owner id)
*/
public Photo uploadPhotoToWall(String filePath, long userID){
try {
String uploadServer=photosGetWallUploadServer(userID, null);
HttpClient client=new DefaultHttpClient();
HttpPost httpPost=new HttpPost(uploadServer);
MultipartEntity albumArtEntity = new MultipartEntity();
albumArtEntity.addPart("photo", new FileBody(new File(filePath)));
httpPost.setEntity(albumArtEntity);
HttpResponse response=client.execute(httpPost);
BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
StringBuilder builder = new StringBuilder();
for (String line; (line = reader.readLine()) != null;) {
builder.append(line).append("\n");
}
JSONObject photoObject = new JSONObject(builder.toString());
return saveWallPhoto(photoObject.get("server").toString(), photoObject.get("photo").toString(), photoObject.get("hash").toString(), userID, null).get(0);
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
} catch (JSONException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings File Templates.
} catch (KException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
return null;
}
2) This function will return photo id, so you'll be able to use wall. savePost() method to post the bitmap. Like this:
long photoPid = account.api.uploadPhotoToWall(bitmapFilePath, account.user_id).pid;
Collection<String> attachments = new ArrayList<String>();
String att = "photo" + account.user_id + "_" + photoPid;
attachments.add(att);
api.createWallPost(account.user_id, text, attachments, null, false, false, false, null, null, null, null);
If you have any questions, feel free to ask.