-3

I want to share the bitmap that I stored locally in my phone to twitter via my android application. Is it possible? Thank You!

Sreejith SP
  • 171
  • 3
  • 22

1 Answers1

3

Yes you can give this code a try

try {
    Intent shareIntent = new Intent(Intent.ACTION_SEND);
    Uri phototUri = Uri.parse("file:///sdcard/Pictures/yourimage.png");
    shareIntent.setType("image/png");
    shareIntent.putExtra(Intent.EXTRA_STREAM, phototUri);
    shareIntent.setClassName("com.twitter.android","com.twitter.android.PostActivity");
    startActivity(Intent.createChooser(shareIntent, "Share Image"));
} catch (Exception e) {
    Intent i = new Intent();
    i.putExtra(Intent.EXTRA_TEXT, message);
    i.setAction(Intent.ACTION_VIEW);
    i.setData(Uri.parse("https://mobile.twitter.com/compose/tweet"));
    startActivity(i);
}
the-ginger-geek
  • 7,041
  • 4
  • 27
  • 45