import { UTSAndroid } from "io.dcloud.uts";
import Context from "android.content.Context"
import CameraManager from "android.hardware.camera2.CameraManager"
import CameraAccessException from "android.hardware.camera2.CameraAccessException"
export const queryCameraCount = () => {
let permission = ["android.permission.CAMERA"]
let denied = UTSAndroid.checkSystemPermissionGranted(UTSAndroid.getUniActivity()!, permission)
if (!denied) {
UTSAndroid.requestSystemPermission(UTSAndroid.getUniActivity()!, permission, function (allRight : boolean, grantedList : string[]) {
if (allRight) {
const d = UTSAndroid.getAppContext()
const e = d?.getSystemService(Context.CAMERA_SERVICE) as CameraManager;
console.log(e.getCameraIdList())
} else {
// 用户仅同意了 grantedList中的权限
}
}, function (doNotAskAgain : boolean, grantedList : string[]) {
// 用户拒绝了部分权限,仅允许了grantedList中的权限
if (doNotAskAgain) {
// 用户拒绝了权限,并且选择不再询问
}
})
}else{
const d = UTSAndroid.getAppContext()
const e = d?.getSystemService(Context.CAMERA_SERVICE) as CameraManager;
let a = e.getCameraIdList();
console.log(a)
}
}
即时通讯开发
我的貌似和他的问题差不多也是e里面的方法调用不出来
2024-01-24 14:38
即时通讯开发
这个没有报错,a打印返回的是个空对象
2024-01-24 15:22
DCloud_Android_DQQ
回复 即时通讯开发: 提供一下复现问题的最简示例 我看看
2024-01-24 17:00
即时通讯开发
回复 DCloud_Android_DQQ: 示例在楼下,大佬
2024-01-24 17:04