0

I am trying to post picture,message,caption,link.expect image remaining is posting fine. if i give url for picture it work.but i want to send drawable image.image is not posting I tried below code:

class LoginDialogListener implements DialogListener {
    public void onComplete(Bundle values) {

        publishFeedDialog();

    }
    public void onFacebookError(FacebookError error) {
        showToast("Authentication with Facebook failed!");
        finish();
    }
    public void onError(DialogError error) {
        showToast("Authentication with Facebook failed!");
        finish();
    }
    public void onCancel() {
        showToast("Authentication with Facebook cancelled!");
        finish();
    }
}



private void publishFeedDialog() {
    final Bundle params = new Bundle();
  final Bitmap bit=BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    bit.compress(CompressFormat.JPEG, 100, baos);
    byte[] data = baos.toByteArray();


    params.putString("to", Universal.ids);
    params.putString(Facebook.TOKEN, facebook.getAccessToken());
    params.putString("name", "Sending a birthday card!");
    params.putString("link", "https://play.google.com/store/search?q=dbgr&c=apps&hl=en");
     params.putString("description", "Wishing You a HAPPY BIRTHDAY");
     params.putString("picture", data);



    facebook.dialog(this, "feed", params, new DialogListener() {

        @Override
        public void onFacebookError(FacebookError e) {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook failed!");
            finish();
        }

        @Override
        public void onError(DialogError e) {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook failed!");
            finish();
        }

        @Override
        public void onComplete(Bundle values) {
            // TODO Auto-generated method stub
            showToast("Post is successfully sent");
            finish();
            Intent i=new Intent(getApplicationContext(),FrndActivity.class);
            startActivity(i);

        }

        @Override
        public void onCancel() {
            // TODO Auto-generated method stub
            showToast("Authentication with Facebook cancelled!");
            finish();
        }
    });

image is not posting.please help me.

user3331192
  • 21
  • 1
  • 7

1 Answers1

0

The feed dialog's "picture" parameter does not support uploading bitmaps, only urls.

https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.0

Ming Li
  • 15,672
  • 3
  • 37
  • 35
  • thanks for reply.which method is use to post the bitmap from drawable. – user3331192 May 10 '14 at 05:09
  • Have a look at the FacebookDialog class (it will require you to use the new APIs, since from your code, it looks like you're still using the old deprecated ways of getting an access token) - https://developers.facebook.com/docs/reference/android/current/class/FacebookDialog/ There are many ways to share in there, and they require the Facebook app to be installed. – Ming Li May 13 '14 at 16:48
  • thanks for reply.i have another problem,i am getting friends profile picture with there names and set in to listview but profile pictures is not matching with there names.picture is not getting correctly – user3331192 May 14 '14 at 05:22
  • See the Link for my question.Profile picture is not matching there names http://stackoverflow.com/questions/23466614/friends-profile-picture-is-not-matching-with-the-profile-name-for-facebook-in-an – user3331192 May 15 '14 at 05:45