Android: Share an image to other apps

0 comments

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

Related Posts

0 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.

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog