Text message sending. Some models can send text messages to specified mobile phones in the background without prompting them. Some models may remind users to decide whether to send messages or not, I think this is for security reasons.
To send a text message, we can register a receiver to check whether the message is successfully sent and whether the recipient has received the message.
/*** Send SMS ** @ Param friend_num * @ Param smsmsg */private void sendsms (string friend_num, string smsmsmsg) {string sent_sms_action = "sent_sms_action "; intent sentintent = new intent (sent_sms_action); pendingintent sentpi = pendingintent. getbroadcast (this, 0, sentintent, 0); // register the broadcast receiversthis. registerreceiver (New broadcastreceiver () {@ overridepublic void onreceive (context _ context, intent _ intent) {Switch (getresultcode () {Case activity. result_ OK: // toast. maketext (this, "sms sent successfully", toast. length_short )//. show (); break; Case smsmanager. result_error_generic_failure: break; Case smsmanager. result_error_radio_off: break; Case smsmanager. criteria: Break ;}}, new intentfilter (sent_sms_action); string delivered_sms_action = "required"; // create the deilverintent parameterintent deliverintent = new intent (delivered_sms_action ); pendingintent deliverpi = pendingintent. getbroadcast (this, 0, deliverintent, 0); this. registerreceiver (New broadcastreceiver () {@ overridepublic void onreceive (context _ context, intent _ intent) {// toast. maketext (this, "the recipient has successfully received", toast. length_short ). show () ;}, new intentfilter (delivered_sms_action); // call the SMS interface to send a text message to smsmanager = smsmanager. getdefault (); List <string> dividecontents = smsmanager. dividemessage (smsmsg); // The text message may be too long and can be sent in two separate messages. If the message contains something coherent, it is better to manually split the message for (string text: dividecontents) {smsmanager. sendtextmessage (friend_num, null, text, sentpi, deliverpi );}}
Text message interception, this function is a bit unreliable, some models cannot intercept text messages (My M1s, 360, QQ Mobile Phone Manager can not intercept) the mobile phone has a built-in SMS interception software with the highest priority, but most mobile phones can still intercept it, but there is also a problem, because the broadcast triggered by SMS reception is ordered broadcast, it is delivered in the first-level and later stages. No matter which level of broadcast can be cut off, subsequent broadcasts cannot be received, the priority issue between applications with the same features is that mobile phone QQ manager is doing better than 360 in this aspect and has a higher priority. Our own text message interception software can also eliminate 360 of the attacks, but QQ is hard to do...