title: Android email intent only *sometimes* does not send attachment?
body: <p>In an app I have, users submit files to a specified email address a lot. It seems 95%+ have no problem, but this is a particular issue that seems to affect some users, and only sometimes. But frequently enough to be annoying.</p>
  <p><strong>Their email sends, but there is no attachment.</strong> They will try 2,3,4 times and <strong>eventually</strong> it will send with the attachment. From one user, I have learned they use Gmail and <em>DO</em> see the attachment prior to pressing &quot;send&quot;.</p>
  <p><strong>The users' Android API levels vary from 19 to 29 and everything in between.</strong></p>
  <p>Here is the code for composing the email intent:</p>
  <pre><code>public int emailSubmission(File fileToSend)
  {
      Uri uri = null;
  
      if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.M)
          uri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() + &quot;.provider&quot;, fileToSend);
      else
          uri = Uri.fromFile(fileToSend);
  
      Intent intent = new Intent(Intent.ACTION_SEND);
  
      intent.setType(&quot;text/message&quot;);
      intent.putExtra(Intent.EXTRA_EMAIL, new String[]{&quot;email@email.com&quot;});
      intent.putExtra(Intent.EXTRA_SUBJECT, &quot;Subject&quot;);
      intent.putExtra(Intent.EXTRA_TEXT, &quot;Hello world!&quot;);
      intent.putExtra(Intent.EXTRA_STREAM, uri);
  
      try
      {
          startActivity(Intent.createChooser(intent, &quot;Email submission...&quot;));
      }
      catch (ActivityNotFoundException e)
      {
          logNonFatalException(e);
          return 2;
      }
  
      return 1;
  }
  </code></pre>
  <p>It seems pretty standard, but I can't figure out what is causing this problem? I also do not know if it is specific to Gmail. Is there anything else I can even try to get rid of this intermittent issue? All &quot;email intent&quot; Android code I see online looks just like this, specifically for attachments and EXTRA_STREAM and the URI code.</p>