Thursday, October 6, 2011

Android: Share an image to other apps

The last post was about receiving shared images.

To send off images to another app, just use:

Intent intent;
File file;

file = new File(absolute_filename);
intent = new Intent(Intent.ACTION_SEND);
intent.setType("image/jpeg");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));

startActivity(Intent.createChooser(intent, "Share photo"));

If you need to be particular about the mime type, see get file mime type from filename.

Sources

No comments:

Post a Comment

Leave your thoughts ...

---
If you are having trouble with copy/pasting in comments, you need to sign in or click 'Preview'.

For more information about this Firefox bug, see here.