UTSAndroid.onAppActivityResult((requestCode : Int, resultCode : Int, data ?: Intent) => {
if (requestCode == 1001) {
let uri = data?.getData();
if (uri != null) {
const projection : Array<string> = ["_data"] as Array<string>;
const context = UTSAndroid.getAppContext() as Context;
if (context != null) {
const resolver = context.getContentResolver();
let tmp : Array<string> = [];
// 下面这行代码报错了。第一个null值
const cursor = resolver.query(uri, projection, null, null, null)
if (cursor != null && cursor.moveToFirst()) {
const cursorIndex = cursor.getColumnIndexOrThrow("_data");
}
}
console.log(uri.getAuthority());
}
console.log(data?.getData());
console.log(data?.getClipData())
}
});
控制台报错:
10:13:22.761 [plugin:uni:app-uts] 编译失败
10:13:22.761 error: 类型不匹配: 推断类型是UTSArray<String>,但预期的是Array<(out) String!>?(可为空的Array<(out) String!>)。
10:13:22.761 at docs/docList.uvue:53:42
1 个回复
阿布朱朱
你好,解决了吗?