Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25541] Android: EmailDialog file attachments not working on Android 7 and higher

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-01-19T23:16:27.000+0000
Affected Version/sRelease 6.2.2
Fix Version/sRelease 7.0.2
ComponentsAndroid
Labelsandroid, email, emaildialog
ReporterJoshua Quick
AssigneeJoshua Quick
Created2017-11-20T22:36:28.000+0000
Updated2018-04-20T21:54:54.000+0000

Description

*Summary:* As of Titanium 6.2.2, the EmailDialog fails to attach files on Android 7.0 and newer OS versions. *Steps to reproduce:*

Set up a project using Titanium 6.2.2 or higher.

Build and run the app on an Android 7.0 or newer device.

Tap on the "Send E-Mail" button.

var window = Ti.UI.createWindow();
var button = Ti.UI.createButton({ title: "Send E-Mail" });
button.addEventListener("click", function(e) {
	var file1 = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "File1.txt");
	file1.write("Hello World!");
	var file2 = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory, "File2.txt");
	file2.write("This is a test.");
	var dialog = Ti.UI.createEmailDialog();
	dialog.subject = "E-Mail Test";
	dialog.toRecipients = ["john.doe@domain.com", "jane.doe@domain.com"];
	dialog.messageBody = "This is the e-mail's body.\nThis is the second line.";
	dialog.addAttachment(file1);
	dialog.addAttachment(file2);
	dialog.open();
});
window.add(button);
window.open();
*Result:* An e-mail window gets displayed, but notice that there are no file attachments. This is the bug. *Expected Result:* There should be 2 files attached to the e-mail, "File1.txt" and "File2.txt". *Work-Around:* In Titanium 7.0.0 and higher, you can target API Level 23 in the "tiapp.xml" file to work-around this issue.
<android xmlns:android="http://schemas.android.com/apk/res/android">
	<manifest>
		<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="23"/>
	</manifest>
</android>
For Titanium 6.3.x and 6.2.2, there is no work-around. You must build with Titanium 6.2.1 or older instead.

Comments

  1. Joshua Quick 2017-11-20

    The following PR is a community made fix, but it's a work-in-progress... https://github.com/appcelerator/titanium_mobile/pull/9520
  2. Joshua Quick 2017-11-30

    Work is complete. PR (master): https://github.com/appcelerator/titanium_mobile/pull/9520
  3. Joshua Quick 2018-01-09

    PR (7.0.x): https://github.com/appcelerator/titanium_mobile/pull/9709
  4. Lokesh Choudhary 2018-01-10

    FR passed for master & PR merged. FR passed for backport , waiting for merge to get enabled.
  5. Lokesh Choudhary 2018-01-19

    Master & backport Pr's merged.
  6. Lokesh Choudhary 2018-01-22

    Verified the fix with SDK 7.1.0.v20180121202754 & 7.0.2.v20180119173957. Closing. Studio Ver: 5.0.0.201712081732 SDK Ver: 7.0.2.v20180119173957, 7.1.0.v20180121202754 OS Ver: 10.13.2 Xcode Ver: Xcode 9.2 Appc NPM: 4.2.11 Appc CLI: 7.0.1 Daemon Ver: 1.0.1 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.10 Node Ver: 8.9.1 NPM Ver: 5.5.1 Java Ver: 1.8.0_101 Devices: samsung SM-G955U1 --- Android 7.0 google Nexus 5 --- Android 6.0.1 google Pixel --- Android 7.1.1

JSON Source