Android Apidemos Sample resolution: App->service->local Service Controller

Source: Internet
Author: User

The Local Service Controller uses LocalService as a "started" service, which is much simpler than the "Bound" service, Localserviceactivities.controller starts the local Service and basically doesn't care about LocalService.

StartService (New Intent (Controller.this,     
 localservice.class));

LocalService can choose to stop himself, in this case by calling StopService to stop the service, if you start the service in this example, no stopservice, the service will run in the background, Even if you quit Appdemo or start another application (a triangle will always appear above the screen). And for the local service Binding, the situation is different, after binding service, even if you do not click the "Unbind Service" button, press "Back" key, Binding activity exit, The Android system will automatically disconnect from the LocalService binding. The notification at the top of the screen will automatically disappear.

In addition, in this case LocalService is called the "local" Service, except for the invocation interface between the provided IBinder objects mentioned above, only the same application component is allowed to invoke outside. LocalService is defined in Androidmanifest.xml as:

<service android:name= ". App. LocalService "/>

Does not contain any intent-filter, means that only the service class can be specified through explicit, and different applications generally cannot access this class directly.

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.