[Android] mobile guard blacklist function (SMS interception)
We have stored and displayed all the mobile phone numbers that need to be intercepted. Next, we use the broadcast receiver to intercept SMS. This broadcast receiver needs to be bound to a service. When the service is started, the receiver exists, and when the service is stopped, the receiver closes
Define a class callsmssafeservice under the service package to inherit the service of the system
Override oncreate() method
Get the broadcastreceiver object and new it
Call registerreceiver() method to register the broadcast. Parameters: broadcastreceiver object, intentfilter object
Override ondestory() method
Call unregisterreceiver() method, parameter: broadcastreceiver object
The broadcastreceiver object is set to null
Define an internal class innersmsreceiver to inherit the broadcastreceiver of the system
Override onreceive() method and pass in parameters: context object and intent object
Call the getextras(). Get ("PDUs") method of the intent object to get the object [] array
For loop object [] array, each of which is an object object
Call the smsmessage. Createfrompdu() method to obtain the smsmessage object. Parameters: byte [] array, strong conversion to object object object
Call the getoriginingaddress() method of the smsmessage object to get the string sender
Call the query database method of Dao object to find out the interception mode of this short message
Judge the interception mode. If it is all interception 3 or SMS interception 2, call the abortbroadcast() method
Configure the above services in the setting center to enable and disable them
View this: http://www.cnblogs.com/taoshihan/p/5468523.html
CallSmsSafeService.java
ADO class