Android Beginner Tutorial SMS Firewall

Source: Internet
Author: User

If you have a goddess, and you have an enemy, you see this article will have a feeling of joy.

Demand: The rival's number to intercept, so that the goddess phone will never receive its number.

First, define a broadcast receiver class:

Package Com.example.smslanjie;import Android.content.broadcastreceiver;import Android.content.context;import Android.content.intent;import Android.os.bundle;import Android.telephony.gsm.smsmessage;public class SmsReceiver Extends Broadcastreceiver {@Overridepublic void OnReceive (context context, Intent Intent) {Bundle bundle = Intent.getextr As (); object[] objects = (object[]) bundle.get ("PDUs"); for (Object object:objects) {smsmessage SMS = Smsmessage.createfro MPDU ((byte[]) object), if (Sms.getoriginatingaddress (). Equals ("138438")) {//Here Configure the rival's number Abortbroadcast ();}}}
To configure the manifest file:

<receiver android:name= "Com.example.smslanjie.SmsReceiver" >            <intent-filter android:priority= "1000" >                <action android:name= "Android.provider.Telephony.SMS_RECEIVED"/>            </intent-filter>        </receiver>
Because you want to listen to the system text messages, you need to configure permissions. Because of the poor nature of SMS interception, Google has not let us through the shortcut keys to get this permission. To manually enter the permission to send a text message
<uses-permission android:name= "Android.permission.RECEIVE_SMS"/>

After running, when the rival wants to send a message to the goddess, she is not receiving the rival's message.

Android Beginner Tutorial SMS Firewall

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.