Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25439] Android: Intent extra 'file://' URI not working on Android 7 or higher

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2017-10-30T20:27:58.000+0000
Affected Version/sn/a
Fix Version/sRelease 6.3.0
ComponentsAndroid
LabelsAndroid, File, Intent
ReporterJorge Macias Garcia
AssigneeGary Mathews
Created2017-10-24T11:26:34.000+0000
Updated2018-05-16T22:49:59.000+0000

Description

Affects 6.2.2, 6.3.X on Android 8. It works on Android 7 and 7.1 Android N sets a new restriction in the use of URIs. It must be a Content URI instead a file URI. In that case, if we try to share some file throught nativePath it fails. Steps: Read some file in your app (be sure it is placed in the external storage), after that try to share it via intent chooser:
        var file = Ti.Filesystem.getFile(Ti.Filesystem.externalStorageDirectory, 'example.pdf');
        var intent = Ti.Android.createIntent({
         action: Ti.Android.ACTION_SEND,
         type: file.read()
           .getMimeType()
       });

       intent.addCategory(Ti.Android.CATEGORY_DEFAULT);
       //In this point nativePath is 'file://' URI. It will throw the exception
       intent.putExtraUri(Ti.Android.EXTRA_STREAM, file.nativePath);

       var chooser = Ti.Android.createIntentChooser(intent, 'Share');

       $.win.activity.startActivity(chooser);

Attachments

FileDateSize
image-2017-10-24-13-21-26-117.png2017-10-24T11:21:27.000+000037577
IntentActionSendTest.js2017-10-27T00:30:59.000+0000720

Comments

  1. Gary Mathews 2017-10-26

    This has been addressed here: https://github.com/appcelerator/titanium_mobile/pull/9559
  2. Joshua Quick 2017-10-27

    The attached [^IntentActionSendTest.js] script can be used to test Intent.putExtraUri() content provider access.
  3. Gary Mathews 2017-10-27

    master: https://github.com/appcelerator/titanium_mobile/pull/9559 6_3_X: https://github.com/appcelerator/titanium_mobile/pull/9566
  4. Lokesh Choudhary 2017-10-30

    FR passed for both master & backport PR's. Backport PR merged. Waiting for master merge to get enabled.
  5. Lokesh Choudhary 2017-10-31

    Verified the fix with SDK 6.3.0.v20171030135813. Studio Ver: 4.10.0.201709271713 OS Ver: 10.12.3 Xcode Ver: Xcode 8.3.3 Appc NPM: 4.2.10-2 Appc CLI: 6.3.0-master.15 Ti CLI Ver: 5.0.14 Alloy Ver: 1.10.6 Node Ver: 7.10.1 Java Ver: 1.8.0_101 Devices: ⇨ google Nexus 6P --- Android 8.0.0 ⇨ google Nexus 5 --- Android 6.0.1
  6. Lokesh Choudhary 2017-11-10

    Master PR merged. Closing.

JSON Source