0

I have made an android app ,I want to share a drawable to twitter,Currently I have done this way for text,But can any buddy tell me how to attach image to intent to share via twitter ,Thank you in advance,My code is as below:

public void shareTwitterIntent() {
        String tweetUrl = "https://twitter.com/intent/tweet?text=3SManiquines";
        Uri uri = Uri.parse(tweetUrl);
        startActivity(new Intent(Intent.ACTION_VIEW, uri));
    }
jigar
  • 31
  • 1
  • 12

1 Answers1

1

Try this (from How to attach a Bitmap when launching ACTION_SEND intent -- perhaps a duplicate?):

String pathofBmp = Images.Media.insertImage(getContentResolver(), bitmap,"title", null);
Uri bmpUri = Uri.parse(pathofBmp);
final Intent emailIntent1 = new Intent(     android.content.Intent.ACTION_SEND);
emailIntent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent1.putExtra(Intent.EXTRA_STREAM, bmpUri);
emailIntent1.setType("image/png");
Community
  • 1
  • 1
Eran Goldin
  • 980
  • 12
  • 21