diff --git a/plugin.xml b/plugin.xml index f712bf7..8e29487 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="1.0.8"> File Opener2 A File Opener Plugin for Cordova. diff --git a/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java b/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java index 32ac492..ee3408a 100644 --- a/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java +++ b/src/android/io/github/pwlin/cordova/plugins/fileopener2/FileOpener2.java @@ -74,12 +74,15 @@ public class FileOpener2 extends CordovaPlugin { } private boolean _open(String fileArg, String contentType, CallbackContext callbackContext) throws JSONException { - - CordovaResourceApi resourceApi = webView.getResourceApi(); - - Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg)); - String fileName = org.apache.cordova.FileHelper.stripFileProtocol(fileUri.toString()); - + String fileName = ""; + try { + CordovaResourceApi resourceApi = webView.getResourceApi(); + Uri fileUri = resourceApi.remapUri(Uri.parse(fileArg)); + fileName = org.apache.cordova.FileHelper.stripFileProtocol(fileUri.toString()); + } catch (Exception e) { + fileName = fileArg; + } + File file = new File(fileName); if (file.exists()) {