Intent share = new Intent(Intent.ACTION_SEND);
// If you want to share a png image only, you can do:
// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");
// if you share video you can use
// shareType("Video/*);
// Make sure you put example png image named myImage.png in your
// directory
String image = Environment.getExternalStorageDirectory()
+ "/myImage.png";
File imageToShare = new File(image);
Uri uri = Uri.fromFile(imageToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Image!"));
// If you want to share a png image only, you can do:
// setType("image/png"); OR for jpeg: setType("image/jpeg");
share.setType("image/*");
// if you share video you can use
// shareType("Video/*);
// Make sure you put example png image named myImage.png in your
// directory
String image = Environment.getExternalStorageDirectory()
+ "/myImage.png";
File imageToShare = new File(image);
Uri uri = Uri.fromFile(imageToShare);
share.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(Intent.createChooser(share, "Share Image!"));
No comments:
Post a Comment