您好,登錄后才能下訂單哦!
今天小編給大家分享一下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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。