Issue
i have a problem to share a ".zip" file with gmail app or otherwise email sender with Android 11.
Intent email_intent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto",mailTo, null));
email_intent.putExtra(Intent.EXTRA_SUBJECT, "Log App");
email_intent.putExtra(Intent.EXTRA_TEXT,"");
email_intent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(getApplicationContext(), BuildConfig.APPLICATION_ID+".provider",new File(log)));
startActivity(Intent.createChooser(email_intent, getString(R.string.invia_tramite)));
I'm not using requestLegacy etc.. but getExternalFilesDir. With lower version of 11 it works.
Please save my day :)
Thanks
Solution
solved with replacing:
Intent email_intent = new Intent(Intent.ACTION_SEND);
email_intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
and in manifest putting:
<queries>
<intent>
<action android:name="android.intent.action.SEND"/>
<data android:mimeType="*/*" />
</intent>
</queries>
Answered By - Lorenzo Sogliani
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.