1

Hello friends i want to share text and sdcard image at a same time with using share intent in android below is my code in on button click.

    Intent share = new Intent(android.content.Intent.ACTION_SEND);
    share.setType("text/plain,image/*");
    String imagePath = Environment.getExternalStorageDirectory()
            + "/myfolder/1407156604780.png";
    File imageFileToShare = new File(imagePath);
    Uri uri = Uri.fromFile(imageFileToShare);
    share.putExtra(Intent.EXTRA_STREAM, uri);
    share.putExtra(Intent.EXTRA_SUBJECT, "Title Of The Post");
    share.putExtra(Intent.EXTRA_TEXT, "fdsfdsfdsfds");
    startActivity(Intent.createChooser(share, "Share image to..."));

using above code share dialog is open but facebook option not show to me ,but in my device facebook application already there so hoe can i set multiple setType property for text as well as image share to facebook ?

Harshal Kalavadiya
  • 2,412
  • 4
  • 38
  • 71
  • 1
    when you share on fab what you see in dialog box ? – Usman Kurd Aug 05 '14 at 07:04
  • Try just share.setType("text/plain"); My code looks identical except for that line and works fine. – Eric Cochran Aug 05 '14 at 07:06
  • Look into this..http://stackoverflow.com/questions/8296605/problems-sharing-combined-text-and-image-with-share-intent-on-twitter..hope it will helps you alot. – Born To Win Aug 05 '14 at 07:08
  • Hii i have tried but using intent you can not share text default you can share only image for text you have to manually enter text after dialog is display twitte is allow but facebook is not allowed default text – Mahesh Aug 05 '14 at 07:14
  • @ Born To Win : when i use setType("*/*") and shre with facebook option it will give me toast like **"please attach only photos or a single videos"** – Harshal Kalavadiya Aug 05 '14 at 07:15
  • @Mahesh is correct. Facebook does not allow you to prefill the text in a status update, so it will simply ignore the text. – Ming Li Aug 06 '14 at 23:37

1 Answers1

0

First of all,facebook doesnt allows sharing text using share intent,instead we need to use facebook sdk. All other social medias except facebook and instagram supports the below code. but you can see facebook and all other installed apps in the poopup dilog

      Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.setType("text/plain");
            shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject");
            shareIntent.putExtra(Intent.EXTRA_TEXT, "text");
            shareIntent.putExtra(Intent.EXTRA_STREAM, image);
            shareIntent.setType("image/*");
            // Launch sharing dialog for image
            startActivity(Intent.createChooser(shareIntent, "Share"));

try it..

max
  • 263
  • 2
  • 16