How to post drawable image on facebook

611 Views Asked by At

Hi I am new to android programming. I am creating a app in which user can share a specific image on facebook. Image is present in my drawable folder. Everything works fine except posting image. I mean I have successfully posted link an description but not image. I have tried may almost every code snippet, present on stackoverflow, to fix this issue but all in vain.

Please help me in solving this problem. Bundle of thanks in advance!

fb= new Facebook(app_id);

     byte[] data = null;


     Bitmap bi = BitmapFactory.decodeResource(getResources(), mImageIds[pos]);
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
     bi.compress(Bitmap.CompressFormat.JPEG, 100, baos);
     data = baos.toByteArray();



    Bundle params = new Bundle(); 
    params.putString("message", "Yasin");
    params.putString("link", "http://www.google.com");
    params.putString("name", "Yasin"); 
    params.putByteArray("picture", data);
    params.putString("description", "This is description"); 
     // displaying facebook dialogs
    fb.dialog(con, "feed", params,new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onError(DialogError e) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onCancel() {
            // TODO Auto-generated method stub

        }
    });     
0

There are 0 best solutions below