Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-25541

Android: EmailDialog file attachments not working on Android 7 and higher

    Details

    • Story Points:
      3

      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:

      1. Set up a project using Titanium 6.2.2 or higher.
      2. Build and run the app on an Android 7.0 or newer device.
      3. 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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jquick Joshua Quick
                Reporter:
                jquick Joshua Quick
                Reviewer:
                Gary Mathews
                Tester:
                Lokesh Choudhary
              • Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Git Source Code