I Can\'t able to upload the images on the facebook from SD card...I used below code....but it did not give me error but at the same time it did not upload the images
You have to do this:
mAsyncRunner = new AsyncFacebookRunner(fbObj);
mAsyncRunner.request(null, parameters, "POST",
new RequestListener() {
@Override
public void onMalformedURLException(
MalformedURLException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFileNotFoundException(
FileNotFoundException e, Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.i("upload", "image uploaded!!!! " + response);
}
}, null);
Try below Snippet for Post Image from SDCard :
Convert your image to bitmap and proceed
private void postToWall() {
AsyncFacebookRunner mAsyncRunner = new AsyncFacebookRunner(facebook);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, stream); // where bm is bitmap from Sdcard
byte[] byteArray = stream.toByteArray();
Bundle param = new Bundle();
param = new Bundle();
param.putString("message", "All");
param.putString("filename", "TEst");
param.putByteArray("image", byteArray);
mAsyncRunner.request("me/photos", param, "POST", new fbRequestListener(), null);
}
public class fbRequestListener implements RequestListener {
@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+response);
}
@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
@Override
public void onFileNotFoundException(FileNotFoundException e,
Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
@Override
public void onMalformedURLException(MalformedURLException e,
Object state) {
// TODO Auto-generated method stub
}
@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub
Log.d("RESPONSE",""+e);
}
}