androidfacebookimagetextshare

How to share image and text to facebook app


I am trying to share an image and text. When I'm doing this:

Intent share = new Intent(Intent.ACTION_SEND);
        share.setType("image/*");
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        screenshot.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
        File f = new File(Environment.getExternalStorageDirectory()
                + File.separator + "temporary_file.jpg");
        try {
            f.createNewFile();
            FileOutputStream fo = new FileOutputStream(f);
            fo.write(bytes.toByteArray());
        } catch (IOException e) {
            e.printStackTrace();
        }
        share.putExtra(Intent.EXTRA_STREAM,
                Uri.parse("file:///sdcard/temporary_file.jpg"));
        share.putExtra(android.content.Intent.EXTRA_TEXT, textToShare);
        startActivityForResult(Intent.createChooser(share, "Share Image"),
                FROM_SHARE);

It works greate on all apps (that was choosen from the popup dialog like Gmail) except for facebook, facebook takes only the image and not the text. Is there a whay to pass an extra text with an image to the facebook app? Thanks!


Solution

  • There is a bug in FACEBOOK I have the same problem If you really want to do that anyhow you need to use facebook SDK for that and use Facebook ShareDialog.