diff --git a/pages/SyntaxCase/utsAndroid.uvue b/pages/SyntaxCase/utsAndroid.uvue index 3787a7fd0dba44ef2bcbf35fbf23219a6b31336c..60ed44c038c2c88e7efb19d506d4391ef84a98d1 100644 --- a/pages/SyntaxCase/utsAndroid.uvue +++ b/pages/SyntaxCase/utsAndroid.uvue @@ -18,6 +18,8 @@ + + 1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。 @@ -67,6 +69,7 @@ import { gotoCameraTake, getDeviceInfoTest, privacyStateTest, + privacyStateCallBackTest } from '@/uni_modules/uts-platform-api' import File from 'java.io.File'; import Intent from 'android.content.Intent'; @@ -106,6 +109,20 @@ export default { } }) }, + privacyStateCallBackClick() { + privacyStateCallBackTest(function(ret, desc) { + if (ret) { + uni.showToast({ + title: '测试通过' + }) + } else { + uni.showToast({ + icon: 'none', + title: '失败:' + desc + }) + } + }) + }, getDeviceInfoClick() { this.text = getDeviceInfoTest() }, diff --git a/pages/SyntaxCase/utsAndroid.vue b/pages/SyntaxCase/utsAndroid.vue index c1b6a36d31f52115cc3c006cb349e62c34567341..3105df433e500c8fc0df1bb28dba8f4d51d0f4cd 100644 --- a/pages/SyntaxCase/utsAndroid.vue +++ b/pages/SyntaxCase/utsAndroid.vue @@ -17,6 +17,7 @@ + 1. 当前页面已通过initAppLifecycle函数注册了生命周期监听。 @@ -60,7 +61,8 @@ initAppLifecycle, gotoCameraTake, getDeviceInfoTest, - privacyStateTest + privacyStateTest, + privacyStateCallBackTest } from '@/uni_modules/uts-platform-api' /** * 测试在页面生命周期之外,使用api @@ -95,6 +97,20 @@ } }) }, + privacyStateCallBackClick() { + privacyStateCallBackTest(function(ret, desc) { + if (ret) { + uni.showToast({ + title: '测试通过' + }) + } else { + uni.showToast({ + icon: 'none', + title: '失败:' + desc + }) + } + }) + }, getDeviceInfoClick(){ this.text = getDeviceInfoTest() }, diff --git a/uni_modules/uts-platform-api/utssdk/app-android/index.uts b/uni_modules/uts-platform-api/utssdk/app-android/index.uts index 7395cd633a1beafa2c9adff2fec4a36c1a4d03b4..780ad79f6b977cdcdbeef2c8afa8a9c0609c553f 100644 --- a/uni_modules/uts-platform-api/utssdk/app-android/index.uts +++ b/uni_modules/uts-platform-api/utssdk/app-android/index.uts @@ -81,6 +81,22 @@ export function privacyStateTest(callback : (ret : boolean, desc : string) => vo } +export function privacyStateCallBackTest(callback : (ret : boolean, desc : string) => void) { + let isAgree : boolean = true + const cb = (ret : boolean) => { + console.log('privacyStateCallBackTest->' + ret) + if (ret == isAgree) { + callback(true, "pass") + } else { + callback(false, "callback error") + } + } + // 先重置用户同意状态 + const callBackId=UTSAndroid.registerPrivacyAgreeListener(cb) + UTSAndroid.setPrivacyAgree(isAgree) + UTSAndroid.unRegisterPrivacyAgreeListener(callBackId) +} + /** * UTSAndroid.getAppTempPath 测试示例 */