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