diff --git a/AndroidManifest.xml b/AndroidManifest.xml index 2b6a7e163b440015f4b0f4f96977062cb1c15314..eae83d6fd83c391515a4f90751cf239d5ac55ebc 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -6,16 +6,6 @@ > - - - - 获取设备信息,观察是否符合预期 + @@ -63,6 +64,8 @@ import { privacyStateTest, } from '@/uni_modules/uts-platform-api' +import Intent from 'android.content.Intent'; + /** * 测试在页面生命周期之外,使用api */ @@ -157,6 +160,15 @@ export default { }) } }, + getFileProviderUriClick() { + let file = new java.io.File(UTSAndroid.getResourcePath("static/logo.png")) + const uri = UTSAndroid.getFileProviderUri(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); + }, getAppTempPathClick() { if (getAppTempPathTest()) { uni.showToast({ diff --git a/pages/advance/advance.vue b/pages/advance/advance.vue index b8e961bfd5deb81fb1725ff03f565a6a41b03dc0..a818a57a90c97261426d2fe47c4b184647aab338 100644 --- a/pages/advance/advance.vue +++ b/pages/advance/advance.vue @@ -28,7 +28,7 @@ arrayConvert } from "../../uni_modules/uts-advance"; - import {openFileWithProvider} from '../../uni_modules/uts-nativepage' + import {openFileWithProvider} from '../../uni_modules/uts-advance' export default { data() { diff --git a/uni_modules/uts-advance/utssdk/app-android/index.uts b/uni_modules/uts-advance/utssdk/app-android/index.uts index 6febb54d46376b74165bbb524656b5b4280c13c5..69a5f49f7d34a9c1d0e49cb28445cf2268efa045 100644 --- a/uni_modules/uts-advance/utssdk/app-android/index.uts +++ b/uni_modules/uts-advance/utssdk/app-android/index.uts @@ -554,3 +554,13 @@ export function arrayConvert():boolean{ return true } + +export function openFileWithProvider(url:String){ + let file = new File(UTSAndroid.getResourcePath("static/logo.png")) + const uri = UTSAndroid.getFileProviderUri(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/index.uts b/uni_modules/uts-nativepage/utssdk/app-android/index.uts index fad0cb4d360883b848321252949551f33bfe8e74..5820a8c23992de108a62ba31d43aeca0ba49f9cd 100644 --- a/uni_modules/uts-nativepage/utssdk/app-android/index.uts +++ b/uni_modules/uts-nativepage/utssdk/app-android/index.uts @@ -327,14 +327,5 @@ 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); -} +