Some of the related exercises for SMS in Android. I see an article below I will be from the title of the three aspects of the SMS operation in the Android system to a simple learning.
SMS Send:
Because of the good encapsulation of the method of sending SMS in Android, the development of SMS is very simple.
public static void SendMessage (context context, string content, String phonenumber) { Smsmanager SMS = smsmanager.getd Efault (); pendingintent pi = pendingintent.getbroadcast (context, 0, New Intent (), 0); Sms.sendtextmessage (PhoneNumber, NULL, content, PI, null); }
Don't forget that there are permissions issues:
SMS Receive:
The reception of short messages is relatively complex. And the reasons for the complexity of the people should also be more easily understood-the reception is not controllable. That means our phone doesn't know when there's going to be a short message coming. Because it is too passive, use the broadcast receiver. We register a broadcast receiver, and then let the broadcast recipient listen to the event as the message arrives. In this way, the passive triggering event is perfectly solved. Let's take a look at this process:
public void OnReceive (context context, Intent Intent) { if (intent.getaction (). Equals (" Android.provider.Telephony.SMS_RECEIVED ")) { Bundle bundle = Intent.getextras (); Object messages[] = (object[]) bundle.get ("PDUs"); Smsmessage smsmessage[] = new Smsmessage[messages.length]; for (int n = 0; n < messages.length; n++) { Smsmessage[n] = SMSMESSAGE.CREATEFROMPDU ((byte[]) messages[n]); } showtoast (context, "SMS content:" + smsmessage[0].getmessagebody ()); } }
Add Permissions:
and a static registration in manifest:
SMS Blocker:
It's a lot easier to do a text interception on the basis of being able to receive text messages. Because it can receive, so I just become the first person to receive, and the received text messages no longer spread downward, this completes the interception of short messages.
Increased priority (10,001-like maximum):
Interruption of transmission:
Android Phone SMS Access