3***@qq.com
3***@qq.com
  • 发布:2023-07-18 14:55
  • 更新:2023-07-19 11:31
  • 阅读:214

华为P50,读取短信,中文变成了英文或越南文

分类:uni-app

获取短信代码;
async getMessage() {
//不同机型可能获取不全
//查看权限是否已允许
var Context = plus.android.runtimeMainActivity();
var res = plus.android.invoke("android.support.v4.app.ActivityCompat", "checkSelfPermission", Context, "android.permission.READ_SMS");
var PERMISSIONS_STORAGE = new Array();
PERMISSIONS_STORAGE.push("android.permission.READ_SMS");
if (res != "0")
{
plus.android.invoke("android.support.v4.app.ActivityCompat", "requestPermissions", Context, PERMISSIONS_STORAGE, 1);
} else {

            }  
            var main = plus.android.runtimeMainActivity();  
            var Uri = plus.android.importClass("android.net.Uri");  
            var ContactsContract = plus.android.importClass('android.provider.ContactsContract');  
            var uri = Uri.parse("content://sms/");  
            var cr = main.getContentResolver();  
            plus.android.importClass(cr);  
            var cur = cr.query(uri, null, null, null, null);  
            plus.android.importClass(cur);  
            cur.moveToFirst();  
            var smslist = [];  
            //console.log(cur);  
            while (cur.moveToNext())   
            {  
                var index_Address = cur.getColumnIndex("address");  
                var address = cur.getString(index_Address);  
                //短信内容  
                var index_Body = cur.getColumnIndex("body");  
                var body = cur.getString(index_Body);  
                //类型1接收 2发送  
                var index_Type = cur.getColumnIndex("type");  
                var type = cur.getString(index_Type);  
                smslist.push({  
                    address:address,  
                    body:body,  
                    type:type  
                })  

            }  
            this.smslist=JSON.stringify(smslist)  
        //  console.log(JSON.stringify(smslist));  
        },
2023-07-18 14:55 负责人:无 分享
已邀请:
FullStack

FullStack - 【插件开发】【专治疑难杂症】【ios上架、马甲包、白包、过审、已成功上架过几百个】【多款插件已上架:https://ext.dcloud.net.cn/publisher?id=22130】【非诚勿扰】QQ:543610866

    //  console.log(JSON.stringify(smslist));    

打印的是什么语言

要回复问题请先登录注册