mirror of
https://gitee.com/shuto/cordova-plugin-file-opener2.git
synced 2025-01-31 03:52:51 +08:00
Merge pull request #302 from AlexMiniApps/master
Fixing the issue #282 - Failed to find configured root that contains "/data/data/{app_name_redacted}/files/"
This commit is contained in:
commit
e8508e786a
@ -27,7 +27,7 @@
|
|||||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||||
</config-file>
|
</config-file>
|
||||||
<config-file target="AndroidManifest.xml" parent="application">
|
<config-file target="AndroidManifest.xml" parent="application">
|
||||||
<provider android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider" android:authorities="${applicationId}.provider" android:exported="false" android:grantUriPermissions="true">
|
<provider android:name="io.github.pwlin.cordova.plugins.fileopener2.FileProvider" android:authorities="${applicationId}.fileOpener2.provider" android:exported="false" android:grantUriPermissions="true">
|
||||||
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
|
<meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/opener_paths" />
|
||||||
</provider>
|
</provider>
|
||||||
</config-file>
|
</config-file>
|
||||||
|
@ -116,7 +116,7 @@ public class FileOpener2 extends CordovaPlugin {
|
|||||||
path = Uri.fromFile(file);
|
path = Uri.fromFile(file);
|
||||||
} else {
|
} else {
|
||||||
Context context = cordova.getActivity().getApplicationContext();
|
Context context = cordova.getActivity().getApplicationContext();
|
||||||
path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".provider", file);
|
path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
|
||||||
}
|
}
|
||||||
intent.setDataAndType(path, contentType);
|
intent.setDataAndType(path, contentType);
|
||||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
@ -124,7 +124,7 @@ public class FileOpener2 extends CordovaPlugin {
|
|||||||
} else {
|
} else {
|
||||||
intent = new Intent(Intent.ACTION_VIEW);
|
intent = new Intent(Intent.ACTION_VIEW);
|
||||||
Context context = cordova.getActivity().getApplicationContext();
|
Context context = cordova.getActivity().getApplicationContext();
|
||||||
Uri path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".provider", file);
|
Uri path = FileProvider.getUriForFile(context, cordova.getActivity().getPackageName() + ".fileOpener2.provider", file);
|
||||||
intent.setDataAndType(path, contentType);
|
intent.setDataAndType(path, contentType);
|
||||||
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user