Skip to content

Instantly share code, notes, and snippets.

@gsrathoreniks
Last active August 9, 2018 13:03
Show Gist options
  • Save gsrathoreniks/3be071fcfccc45059399db4494a72576 to your computer and use it in GitHub Desktop.
Save gsrathoreniks/3be071fcfccc45059399db4494a72576 to your computer and use it in GitHub Desktop.
BitMap bitmap = .......
------------------------------
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.putExtra(Intent.EXTRA_STREAM, getImageUri(getApplicationContext(),bitmap));
sharingIntent.setType("image/jpeg");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "HEADING");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "SOME TEXT TO SHARE WITH IMAGE");
startActivity(Intent.createChooser(sharingIntent, "Share via"));
public Uri getImageUri(Context context,Bitmap bitmap){
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,100,bytes);
String path = MediaStore.Images.Media.insertImage(context.getContentResolver(),bitmap,"Novelty",null);
return Uri.parse(path);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment