Posted By

GunnarHKarlsson on 10/17/11


Tagged

image text android share


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Priestd09


Android share text or image


 / Published in: Java
 

URL: http://stackoverflow.com/questions/3553017/android-share-via-dialog

  1. For sharing an image, like in the example picture, it would be something like this:
  2.  
  3. Intent share = new Intent(Intent.ACTION_SEND);
  4. share.setType("image/jpeg");
  5.  
  6. share.putExtra(Intent.EXTRA_STREAM,
  7. Uri.parse("file:///sdcard/DCIM/Camera/myPic.jpg"));
  8.  
  9. startActivity(Intent.createChooser(share, "Share Image"));
  10. For text you would use something like:
  11.  
  12. Intent share = new Intent(Intent.ACTION_SEND);
  13. share.setType("text/plain");
  14. share.putExtra(Intent.EXTRA_TEXT, "I'm being sent!!");
  15. startActivity(Intent.createChooser(share, "Share Text"));

Report this snippet  

You need to login to post a comment.