I have a problem because on Android 11 I can't send the attachment. The email opens, for example into gmail, but Gmail displays the message couldn't attach file. I read a bunch of posts and instructions for developers, but I didn't find the right solution. ACTION_SENDTO works perfectly on Android 10 and below. Please help, thanks in advance.
Intent intent = new Intent(Intent.ACTION_SENDTO);
intent.setType("text/html");
String message="";
intent.setData(Uri.parse("mailto:"));
intent.putExtra(Intent.EXTRA_SUBJECT, "");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse( "file://" + filelocation));
intent.putExtra(Intent.EXTRA_TEXT, message);
intent.addFlags(Intent.FLAG_ACTIVITY_REQUIRE_NON_BROWSER);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(intent, null));
Manifest:
<queries>
<intent>
<action android:name="android.intent.action.SENDTO" />
<data android:scheme="mailto" />
<category android:name="android.intent.category.DEFAULT" />
</intent>
</queries>