1. Detect the broadcast of the boot
Public classBootreceive extends Broadcastreceiver {@Override Public voidOnReceive (Context context, Intent Intent) {String sim= sptools.getstring (Context, Myconstants.sim,""); Telephonymanager Manger=(Telephonymanager) context. Getsystemservice (Context.telephony_service); String Number=Manger.getsimserialnumber (); if(!sim.equals (number)) {Smsmanager sm=Smsmanager.getdefault (); String Safenumber= Sptools.getstring (Context,myconstants.safenumber,""); /** 1), the destination address of the destinationaddress--message * 2), the address of the scaddress--service center, or null use the current default SMSC 3) destinationport--message The target port number * 4), the body of the data--message, that is, the message to send the data * 5), sentintent--if not empty, when the message successfully sent or failed this pendingintent broadcast * 。 The result code is ACTIVITY.RESULT_OK indicates success *, or result_error_generic_failure, Result_error_radio_off *, Result_erro One of the R_NULL_PDU represents an error *. The corresponding result_error_generic_failure,sentintent may include an additional * "error code" that contains a radio broadcast technology-specific value, usually only useful in repairing a failure. * Every SMS-based application control detection sentintent. If Sentintent is empty *, the caller will detect all unknown applications, which will cause a smaller number of SMS to be sent at the time of Detection. * 6), deliveryintent--if not empty, when the message is successfully transmitted to the recipient this pendingintent is broadcast. * Exception: Throws an IllegalArgumentException exception if destinationaddress or data is empty. */sm.sendtextmessage (Safenumber,"","I lost my phone.",NULL,NULL); } }}bootreceive
Configuration file:
<receiver android:name="com.itheima62.mobileguard.receiver.BootReceive"> <intent-filter > <action android:name="Android.intent.action.BOOT_COMPLETED "/> </intent-filter> </receiver>
configuration file
Add Permissions:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
These broadcasts take a lot of time to open in the service
——————————————————————————————————————————————————————————————————————————————————————————————————————————————— ————————— 2, SCard is hanging in.
The first step : Write a broadcast receiver :
Step two :
To configure in the manifest file
Step three :
Add the appropriate permissions
So when you finally dial out of the phone , If you find a long distance call ...
3. The application is installed / uninstalled :
<receiver android:name= "Com.itheima.appstatus.AppStatus" >
<intent-filter>
<action android:name= "Android.intent.action.PACKAGE_REMOVED"/>
<action android:name= "Android.intent.action.PACKAGE_ADDED"/>
<data android:scheme= "Package"/>
</intent-filter>
</receiver>
Android (20) Popular broadcasts