Broadcast of Android four components (cont.)

Source: Internet
Author: User

1. Which method can send a broadcast?

Activity.sendbroadcast or Context.sentbroadcast or service.sendbroadcast

2. Must the class be inherited by the creation of a broadcast acceptance program?

Broadcastreceiver

3. What are the parameters of the broadcast acceptance procedure?

public void OnReceive (context context, Intent Intent)

The Context in which the receiver is running

The Intent being received

4. How do I register for a broadcast acceptance procedure?

        <receiver            android:name= "Com.htc.globalsearch.imagesearch.service.provider.ImageSearchReceiver"             android:exported= "false" >            <intent-filter>                <action android:name= " Com.htc.intent.action.REBUILDIMAGE "/>            </intent-filter>            <intent-filter>                <action Android:name= "Android.intent.action.BOOT_COMPLETED"/>            </intent-filter>        </receiver>

5. How do you point out that you are interested in feature broadcasts? </intent-filter>

6. Can external programs receive broadcasts?

The reception of the broadcast to see Intent-filter and permission, to satisfy this is acceptable.

7. How do I access the Notification Manager?

Mnotificationmanager = (Notificationmanager)this.getsystemservice (Notification_service);

What is the goal of 8.Intentservice?

Intentservice is a service that starts by Context.startservice (Intent) to handle asynchronous requests, and you only need to inherit intentservice and override them when you use the The Onhandleintent (Intent) method receives a Intent object and stops itself at the appropriate time (usually when the job is completed). All requests are processed in one worker thread, alternating (but not blocking the execution of the main thread), and only one request can be executed at a time.

That is, Intentservice initiates a service and starts the threading process without blocking the main thread.

Intentservice is actually a collection of looper,handler,service, he has not only the function of service, but also the function of processing and looping messages.

14. There are many clients calling Intentservice, so what is the thread corresponding to the client?

1 of them. All operations are performed within one thread. Ensure synchronization through Looper,handle mechanism!

Service to handle complex tasks, you can loop through the thread in Looper,handler Way, and then connect the remote service by AIDL.

What is 15.wakefulintentservice?



Broadcast of Android four components (cont.)

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.