Empty app when exporting to Gmail

Users recently started reporting a problem while sharing files from my Android app using Gmail. The destination is accepted by the empty recipient. I could never play back on my devices, but they sent me such emails and I saw an empty attachment.

This seems to be happening exclusively on Android 7 and above .

Here is how I can share the file in my application:

Intent intent = new Intent(Intent.ACTION_SEND);
intent.setClassName(activityInfo.packageName, activityInfo.name);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_EMAIL, new String[]{"email@domain.com"});
intent.putExtra(Intent.EXTRA_TEXT, "Some text");
intent.putExtra(Intent.EXTRA_SUBJECT, "Subject");
Uri uri = FileProvider.getUriForFile(context, getFileProviderAuthority(), textFile);
intent.putExtra(Intent.EXTRA_STREAM, uri);
context.grantUriPermission(activityInfo.packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(intent);

So far, I have not been able to understand why this is happening for some users and not for others. Most of them seem to have the latest version of Gmail.

One thing that I noticed is that when I look at the original email I receive from these users, those of the problematic users look like this:

----_com.android.email_1901922805148181 
Content-Type: text/html; charset=utf-8 
Content-Transfer-Encoding: base64

*encoded email body*

----_com.android.email_1901922805148181  
Content-Type: text/plain;  name="filename.txt"  
Content-Transfer-Encoding: base64 
Content-Disposition: attachment;  filename="filename.txt";  size=262
----_com.android.email_1901922805148181--

And ordinary users look like this:

--001a1145af74a967fe0566ff756c 
Content-Type: text/html; charset="UTF-8" 
Content-Transfer-Encoding: quoted-printable

*email body*

--001a1145af74a967fe0566ff756c--
--001a1145af74a968010566ff756e 
Content-Type: text/plain; charset="US-ASCII"; name="log.txt" 
Content-Disposition: attachment; filename="log.txt" 
Content-Transfer-Encoding: base64 
Content-ID: <1620c22fd58144d0cc61> X-Attachment-Id: 1620c22fd58144d0cc61

*encoded attachment*

--001a1145af74a968010566ff756e--

Update

, ACTION_SEND, Gmail Google (.. Gmail).

( , EXTRA_TEXT). , . .

+4
1

, ​​ Gmail Android: 8.3.12.190852125

+2

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


All Articles