diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index a50775628701806e5d973e24ccd30423dabdaf83..206c240150d6a9fbb0ed7fab0bd86124d295d96f 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -5,6 +5,15 @@
-
+
+
+
+
diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue
index 3f37c4e97369db72ec0ae844f824e6d9fd58a389..b8e961bfd5deb81fb1725ff03f565a6a41b03dc0 100644
--- a/pages/advance/advance.vue
+++ b/pages/advance/advance.vue
@@ -27,6 +27,8 @@
quitApp,
arrayConvert
} from "../../uni_modules/uts-advance";
+
+ import {openFileWithProvider} from '../../uni_modules/uts-nativepage'
export default {
data() {
@@ -81,7 +83,12 @@
}, {
name: "播放asset音频(需自定义基座)",
url: "advance/android/assetaudio"
- }, {
+ },
+ {
+ name: "使用三方应用打开项目文件(需自定义基座)",
+ function: "testOpenFileWithProvider"
+ },
+ {
name: "操作DecorView",
url: "advance/android/decorview"
}, {
@@ -215,6 +222,9 @@
},
testQuitApp() {
quitApp()
+ },
+ testOpenFileWithProvider() {
+ openFileWithProvider("apps/__UNI__70BE9D0/www/static/logo.png")
},
testArrayConvert() {
let convertRet = arrayConvert()
diff --git a/uni_modules/uts-nativepage/utssdk/app-android/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts
index ca3d0ed3ef9c1e3c7977f5fda804232263caf212..4191d8f290a3e208984d3a85a7d0a7950c1765d8 100644
--- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts
+++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts
@@ -28,6 +28,8 @@ import LayoutInflater from 'android.view.LayoutInflater';
import LinearLayoutManager from 'androidx.recyclerview.widget.LinearLayoutManager';
export {DoAppWidget} from "./DoAppWidget.uts"
import Application from 'android.app.Application';
+import File from 'java.io.File';
+import Uri from 'android.net.Uri';
export class AppHookProxy implements UTSAndroidHookProxy {
@@ -309,3 +311,15 @@ export function gotoDemoActivity():boolean {
}
+
+export function openFileWithProvider(url:String){
+ let file = new File(UTSAndroid.getResourcePath("static/logo.png"))
+ // 这里的 io.dcloud.hellouts.uts_nativepage.fileprovider 应该是你唯一的fileprovider 标识
+ const uri = androidx.core.content.FileProvider.getUriForFile(UTSAndroid.getUniActivity()!,"io.dcloud.hellouts.uts_nativepage.fileprovider",file)
+ console.log("uri",uri.toString())
+ const intent = new Intent(Intent.ACTION_VIEW, uri)
+ intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION) // 添加权限标志
+ const context = UTSAndroid.getUniActivity()!;
+ context.startActivity(intent);
+}
+
diff --git a/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml
new file mode 100644
index 0000000000000000000000000000000000000000..56d22266ec97f29aa4caffecbe466d36285e3d36
--- /dev/null
+++ b/uni_modules/uts-nativepage/utssdk/app-android/res/xml/filepaths.xml
@@ -0,0 +1,4 @@
+
+
+
+
\ No newline at end of file