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:

01.Intent intent;
02.File file;
03. 
04.file = new File(absolute_filename);
05.intent = new Intent(Intent.ACTION_SEND);
06.intent.setType("image/jpeg");
07.intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
08. 
09.startActivity(Intent.createChooser(intent, "Share photo"));

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

Sources

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