0

The code above is for sending an email with an attachment made before(fileToSend2). Works fine below Android Nougat (7.0) but is not working in Android Nougat 7.0 and Oreo 8.0. I update my device to Nougat and it is not working. Maybe for safety reason I must use provider to share the Uri file via intent. Can you help me how to do this?

        Uri u1 = Uri.fromFile(fileToSend2);

        Intent sendIntent = new Intent(Intent.ACTION_SEND);
        sendIntent.putExtra(Intent.EXTRA_SUBJECT, "**Mail subject**");
        sendIntent.putExtra(Intent.EXTRA_TEXT, "mail text");
        sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[]{"igirpenots55@yahoo.com"});
        sendIntent.putExtra(Intent.EXTRA_STREAM, u1);
        sendIntent.setType("text/html");
        startActivity(sendIntent);
Arda Çebi
  • 1,705
  • 4
  • 15
  • 27
Apollon
  • 311
  • 7
  • 29
  • 1
    See https://stackoverflow.com/a/48781636/4168607 – ADM Apr 27 '18 at 14:04
  • Gives me an error in Uri uri = FileProvider.getUriForFile(MainActivity.this, BuildConfig.APPLICATION_ID + ".provider",fileImagePath); in the MainActivity.this. What I have to use there? – Apollon Apr 27 '18 at 14:15
  • 1
    `MainActivity.this` is context . Use your own Activity in place of it . – ADM Apr 27 '18 at 14:17

0 Answers0