您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
今天小编给大家分享一下Auto.js怎么调用系统短信、电话模块的相关知识点,内容详细,逻辑清晰,相信大部分人都还太了解这方面的知识,所以分享这篇文章给大家参考一下,希望大家阅读完这篇文章后有所收获,下面我们一起来了解一下吧。
VS Code
Google nexus5x
Auto.js Pro 7.0.4
win10
importClass(android.content.Intent); importClass(android.telephony.SmsManager); StringBuilder = java.lang.StringBuilder; Uri = android.net.Uri; ArrayList = java.util.ArrayList; List = java.util.List; Context = android.content.Context; SimpleDateFormat=java.text.SimpleDateFormat; Date=java.util.Date; Long=java.lang.Long; var MessageInfo; var list; console.show(); var smsManager = android.telephony.SmsManager.getDefault(); smsManager.sendTextMessage("13888888888", null, "123123", null, null); toast('短信发送成功') console.info('短信发送成功')
importClass(android.net.Uri); importClass(android.database.Cursor); importClass(android.content.ContentResolver); var SMS_INBOX = Uri.parse( "content://sms/" ); var cr = context.getApplicationContext().getContentResolver(); var projection=new Array("_id" , "address" , "person" , "body" , "date" , "type" ); var cur = cr.query(SMS_INBOX, projection, null , null , "date desc" ); var i=0; while (cur.moveToNext()) { i=i+1; var number = cur.getString(cur.getColumnIndex("address"));//手机号 var name = cur.getString(cur.getColumnIndex("person"));//联系人姓名列表 var body = cur.getString(cur.getColumnIndex("body"));//短信内容 toastLog(number); toastLog(name); toastLog(body); if(i>10){break;} }
importPackage(android.content); importClass(android.telephony.SmsMessage); var filter=new IntentFilter(); filter.addAction("android.provider.Telephony.SMS_RECEIVED"); var receiver = new JavaAdapter(android.content.BroadcastReceiver, { onReceive : function(context, intent) { var sender = null; var bundle = intent.getExtras(); var format = intent.getStringExtra("format"); if (bundle != null) { var pdus = bundle.get("pdus"); for (object in pdus) { var message=SmsMessage.createFromPdu(pdus[object],format); sender = message.getOriginatingAddress(); messageBody = (message.getMessageBody()); log("发信人: " + replacepos(sender, 6, 9, "****")); log("短信内容: " + messageBody); } } } }); context.registerReceiver(receiver,filter); setInterval(()=>{},1000); events.on("eixt", function () { context.unregisterReceiver(receiver); }) function replacepos(text,start,stop,replacetext) { mystr = text.substring(0,start)+replacetext+text.substring(stop+1); return mystr; }
function call(context,id, telNum){ // id starts from zero to one importClass(android.content.Intent); importClass(android.net.Uri); importClass(android.content.Context); importClass(android.telecom.TelecomManager); let telecomManager = context.getSystemService(Context.TELECOM_SERVICE); if(telecomManager != null){ let phoneAccountHandleList = telecomManager.getCallCapablePhoneAccounts(); let intent = new Intent(); intent.setAction(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:" + telNum)); intent.putExtra(TelecomManager.EXTRA_PHONE_ACCOUNT_HANDLE, phoneAccountHandleList.get(id)); app.startActivity(intent); } } call(context,0,12345678910)
注意事项
需要先开权限,没有权限会报错Permission denied
开启权限:设置->应用和通知->Auto.js Pro->权限
importClass(android.net.Uri); importClass(android.database.Cursor); importClass(android.content.ContentResolver); var SMS_INBOX = Uri.parse( "content://sms/" ); var cr = context.getApplicationContext().getContentResolver(); var projection=new Array("_id" , "address" , "person" , "body" , "date" , "type" ); var cur = cr.query(SMS_INBOX, projection, null , null , "date desc" ); var i=0; while (cur.moveToNext()) { i=i+1; var number = cur.getString(cur.getColumnIndex("address"));//手机号 var name = cur.getString(cur.getColumnIndex("person"));//联系人姓名列表 var body = cur.getString(cur.getColumnIndex("body"));//短信内容 toastLog(number); toastLog(name); toastLog(body); if(i>10){break;} }
以上就是“Auto.js怎么调用系统短信、电话模块”这篇文章的所有内容,感谢各位的阅读!相信大家阅读完这篇文章都有很大的收获,小编每天都会为大家更新不同的知识,如果还想学习更多的知识,请关注亿速云行业资讯频道。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。