8***@qq.com
8***@qq.com
  • 发布:2022-10-17 14:42
  • 更新:2022-10-17 14:42
  • 阅读:262

获取通话记录,安卓11拿不到第一条数据

分类:HBuilderX

CallLog(){
var CallLog = window.plus.android.importClass('android.provider.CallLog');
var Activity = window.plus.android.runtimeMainActivity();
var ContentResolver = window.plus.android.importClass('android.content.ContentResolver');
var resolver = Activity.getContentResolver();
window.plus.android.importClass(resolver);
var String = window.plus.android.importClass("java.lang.String");
var cs = resolver.query(CallLog.Calls.CONTENT_URI, null, null, null, CallLog.Calls.DEFAULT_SORT_ORDER);

        var talist = [];  
        var count = 0; // 记录多少条 用于处理循环跳出  
        while (window.plus.android.invoke(cs, "moveToNext")) {  
            count++;  
            talist.push({  
                xm: window.plus.android.invoke(cs, "getString", window.plus.android.invoke(cs, "getColumnIndex", CallLog.Calls.CACHED_NAME)),  
                telphone: window.plus.android.invoke(cs, "getString", window.plus.android.invoke(cs, "getColumnIndex", CallLog.Calls.NUMBER)),  
                duration: window.plus.android.invoke(cs, "getString", window.plus.android.invoke(cs, "getColumnIndex", CallLog.Calls.DURATION)),  
                date: this.$utils.formatFullTime(window.plus.android.invoke(cs, "getString", window.plus.android.invoke(cs, "getColumnIndex", CallLog.Calls.DATE))),  
                type: window.plus.android.invoke(cs, "getString", window.plus.android.invoke(cs, "getColumnIndex", CallLog.Calls.TYPE))  
            });  
            if(count > 10){  
                break;  
            }  
        }  
        console.info("talist",JSON.stringify(talist));  
    },
2022-10-17 14:42 负责人:无 分享
已邀请:

该问题目前已经被锁定, 无法添加新回复