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

Android: Intent extra 'file://' URI not working on Android 7 or higher

    Details

      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

          Issue Links

            Activity

              People

              • Assignee:
                gmathews Gary Mathews
                Reporter:
                jormagar Jorge Macias Garcia
                Reviewer:
                Joshua Quick
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-5912
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Source Code