Skip to content

Instantly share code, notes, and snippets.

@lenamuit
Created June 7, 2014 11:15
Show Gist options
  • Save lenamuit/f22a208ff00928a14339 to your computer and use it in GitHub Desktop.
Save lenamuit/f22a208ff00928a14339 to your computer and use it in GitHub Desktop.
Take image from View and share
Bitmap screenshot = Bitmap.createBitmap(_rootView.getWidth(), _rootView.getHeight(), Bitmap.Config.RGB_565);
_rootView.draw(new Canvas(screenshot));
String path = Images.Media.insertImage(getContentResolver(), screenshot, "title", null);
Uri screenshotUri = Uri.parse(path);
final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
emailIntent.putExtra(Intent.EXTRA_STREAM, screenshotUri);
emailIntent.setType("image/png");
startActivity(Intent.createChooser(emailIntent, "Send email using"));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment