Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitsydarel/5c026b159166d23925bde68c59a39145 to your computer and use it in GitHub Desktop.
Save bitsydarel/5c026b159166d23925bde68c59a39145 to your computer and use it in GitHub Desktop.
protected void shareScreenShot() throws IOException {
final Intent shareIntent = new Intent(Intent.ACTION_SEND);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
shareIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
} else {
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
shareIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
shareIntent.setType("image/jpeg");
shareIntent.putExtra(Intent.EXTRA_STREAM, takeScreenShot());
startActivity(Intent.createChooser(shareIntent, getString(R.string.send_to)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment