BroadcastReceiver details, broadcastreceiver

Source: Internet
Author: User

BroadcastReceiver details, broadcastreceiver

 StartBroadcastReceiverTwo steps are required:

 

IsBroadcastReceiverRegister the broadcast address, static registration (IntentFilter), Dynamic Registration (RegisterReceiver)

Static registration:

  <receiver android:name=".MyReceiver">  <intent-filter> <action android:name="android.intent.action.MY_BROADCAST"/> <category android:name="android.intent.category.DEFAULT" /></intent-filter></receiver>

 

 

 

Dynamic Registration:

MyReceiver receiver = new MyReceiver();            IntentFilter filter = new IntentFilter();  filter.addAction("android.intent.action.MY_BROADCAST");            registerReceiver(receiver, filter);  

 

UnregisterReceiver ()

 

Normal broadcast is completely asynchronous for multiple receivers. Generally, each receiver can receive the broadcast without waiting. The receiver does not affect each other. For such broadcast, the receiver cannot terminate the broadcast, that is, it cannot block the receiving actions of other receivers.

 

Terminate broadcast: abortBroadcast ()

 

Http://blog.csdn.net/liuhe688/article/details/6955668

 

 

SendOrderedBroadcast (intent, string) sends ordered broadcast:
Note: When the sendOrderedBroadcast method is used to send an ordered broadcast, a permission parameter is required. If it is null, the recipient is not required to declare the specified permission. If it is not null, it indicates that if the recipient wants to receive the broadcast, the specified permission must be declared.

 

 

The receiving system Broadcaset, for example, after "android. intent. action. BOOT_COMPLETED "," android. permission. ACCESS_NETWORK_STATE ", broadcast; then build and start the service Intent, new Intent (context, service. class); context. startService (intent); Start Service.

 

 

ContentResolver performs CRUD and other data operations on the specified Uri, but the Uri is not the real data core. Therefore, these CRUD operations will be delegated to the ContentProvider corresponding to the Uri.

 

In AndroidManifest. after the provider is configured in xml, when getContentResolver () in the Activity obtains the resolver, and then calls the query, insert, update and other methods through resolve, it actually calls the Provider to perform data operations.

Related Article

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.