- Andorid: Support for both relative and absolute path

- Upped the version to 1.0.8
This commit is contained in:
pwlin 2014-06-18 14:14:04 +02:00
parent 383d2bf514
commit ef5c633f47
2 changed files with 10 additions and 7 deletions

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android" id="io.github.pwlin.cordova.plugins.fileopener2"
version="1.0.7">
version="1.0.8">
<name>File Opener2</name>
<description>A File Opener Plugin for Cordova.</description>

View File

@ -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()) {