How to start a mailbox with an attached image?

I am trying to start an email intent with jpg attached.

I did:

Intent intent4 = new Intent(Intent.ACTION_SENDTO,
Uri.fromParts("mailto", "testemail@gmail.com", null));
startActivity(intent4);

this triggers email activity.

But when I try to add a DataAndType (my jpeg application). He does not work with

android.content.ActivityNotFoundException: No Activity found to handle Intent { action=android.intent.action.SENDTO data=file:///data/data/com.mycompany.mypackage/files/temp-picture type=JPEG 


Intent intent4 = new Intent(Intent.ACTION_SENDTO,
  Uri.fromParts("mailto", "testemail@gmail.com", null));
intent4.setDataAndType(Uri.parse("file://"+ mTempFilePath),
  Bitmap.CompressFormat.JPEG.name());    
startActivity(intent4);
+3
source share
1 answer

Have you tried installing mime manually on "image/jpeg"instead Bitmap.CompressFormat.JPEG.name().

+1
source

Source: https://habr.com/ru/post/1711515/


All Articles