[File Viewer Plugin] Not working on Android 7 Nogut

[File Viewer Plugin] Not working on Android 7 Nogut

  
Forge Component
(4)
Published on 25 Jul (3 weeks ago) by Experts
4 votes
Published on 25 Jul (3 weeks ago) by Experts

Hi,

I am using the downloaded file to open using the File Viewer Plugin.

It is working perfect with Android 5.1 but not working on Android-7.

I am using the Client Action of Plugin - CheckDocumentViewerPlugin & It return true on both device but still not working on Android-7.


Thanks,

Assif

I can confirm this issue.

Harlin Setiadarma wrote:

I can confirm this issue.

Yes,

Did have any work-around for the same.


Outsystem should keep a documentation for each plugin on portal & also specify the version/platforms it supports, That would be much helpful for developers.



Sadly haven't found any workaround.

Solution

Harlin Setiadarma wrote:

Sadly haven't found any workaround.


I found a solution for the issue :)

Previous  I was downloading the file & providing the file path to the plugin, But now I am providing directly the URL to the plugin to open on remote.

What it does, It open it in chrome & download it & then open automatically in viewer.

It works on Andorid 5.1,6 & 7


Solution

Yep, I did that too...

But it's temporary workaround at best.

My client still not satisfied with this approach.

same issue here.

Issue persists.

It's the new security from Android Nougat now reject file:/// uri.

The native code in cordova github must be updated to use the new FileProvider approach.

https://developer.android.com/about/versions/nougat/android-7.0-changes

Sharing Files Between Apps

For apps targeting Android 7.0, the Android framework enforces the StrictMode API policy that prohibits exposing file:// URIs outside your app. If an intent containing a file URI leaves your app, the app fails with a FileUriExposedException exception.

To share files between applications, you should send a content:// URI and grant a temporary access permission on the URI. The easiest way to grant this permission is by using the FileProvider class. For more information on permissions and sharing files, see Sharing Files.


It's fixed in the original cordova plugin: https://github.com/sitewaerts/cordova-plugin-document-viewer


But it's not compatible with Outsystems (I tried), so we all have to wait for this plugin developer to implement it.