I'd like to post an image to facebook by using their graph api. But my image is in drawable folder. So far:
public static void postToFacebook() {
    Bundle params = new Bundle();
    // shared with this
    params.putString("caption", activityContext.getString(R.string.app_name));
    // description of the program
    params.putString("description", "bla bla bla bla bla bla"); 
    // header of the description
    params.putString("name", "train");
    // callback url
    params.putString("link","http://www.google.com.tr");
    // put a personal message
    params.putString("message", "my message");
    // to put a photo
    params.putByteArray("picture", getImageAsData());
    try {
        String response = FacebookUtility.mFacebook.request("/me/feed",
                params, "POST");
        if (response == null || response.equals("")
                || response.equals("false"))
            Toast.makeText(activityContext, "Error.",
                    Toast.LENGTH_SHORT).show();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
public static byte[] getImageAsData() {
Drawable d = activityContext.getResources().getDrawable(R.drawable.icon);
Bitmap bitmap = ((BitmapDrawable) d).getBitmap();
    ByteArrayOutputStream stream = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream);
    byte[] bitmapdata = stream.toByteArray();
    return bitmapdata;
}
But this is not working... It's not posting my icon, but it gets google icon from site. I try to comment out link part, but this time it didn't send anything but message.
I also try to get bitmap as:
Bitmap bitmap = BitmapFactory.decodeResource(activityContext.getResources(), R.drawable.icon);
But this also didn't work out.
I've seen:
Bitmap bi = BitmapFactory.decodeFile(pathonsdcard);
But i couldn't use this method to get bitmap, because i have no pathonsdcard?
Any suggestion? So how can i post image which is located in res/drawable folder ? Thanks in advance.
 
     
     
    