I don\'t find a correct solution to post an image to my facebook wall using facebook sdk. On stackOverflow I found the following solution but AsyncFacebookRunner and mAsyn
You have to use the function newUploadPhotoRequest
see the documentation here :
https://developers.facebook.com/docs/reference/android/3.0/Request#newUploadPhotoRequest%28Session,%20Bitmap,%20Callback%29
The complete solution :
Request.Callback uploadPhotoRequestCallback = new Request.Callback() {
@Override
public void onCompleted(Response response) {
if (response.getError() != null) {
//post error
} else{
String idRploadResponse = (String) response.getGraphObject().getProperty("id");
if (idRploadResponse!= null) {
String fbPhotoAddress = "https://www.facebook.com/photo.php?fbid=" +idRploadResponse;
} else {
//error
}
}
}
};
@SuppressWarnings("deprecation")
public void shareImg(View v) {
Bitmap img = albero.getDrawingCache(); //I get Btimap from View
if (img != null) {
Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), img, uploadPhotoRequestCallback);
Bundle parameters = request.getParameters(); // <-- THIS IS IMPORTANT
parameters.putString("message", "My message");
// add more params here
request.setParameters(parameters);
request.executeAsync();
}
}