Android Phone SMS Access

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.