Android (20) Popular broadcasts

Source: Internet
Author: User

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

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.