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

Source: Internet
Author: User
Tags filter bind

Remote Service Controller and Android Apidemo with local Service sample resolution: App->service->local Service Controller

Is the "started" mode of using the service, and the definition of Remoteservice in Androidmanifest.xml is as follows:

<service android:name= ". App. Remoteservice "android:process=": Remote ">

<intent-filter>

<!–these are the interfaces supported by the service, which

can bind to. –>

<action android:name= "Com.example.android.apis.app.IRemoteService"/>

<action android:name= "Com.example.android.apis.app.ISecondary"/>

<!–this is a action code can use to select the service

Without explicitly supplying the implementation class. –>

<action android:name= "Com.example.android.apis.app.REMOTE_SERVICE"/>

</intent-filter>

</service>

The code to start and stop the service in Remoteservice.controller is much simpler than the "Bound" service mode:

Make sure the service is started.  It would continue running     
//until someone calls StopService ().
We use a action code here, instead of explictly supplying
//The component name, so and other packages can Replac e
//the service.
StartService (New Intent (
 "Com.example.android.apis.app.REMOTE_SERVICE"));

... ...

 Cancel a previous call to StartService ().  Note that the
//service won't actually stop at this point if there are
//still bound clients.
StopService (New Intent (
 "Com.example.android.apis.app.REMOTE_SERVICE"));

The "started" service runs after it is started until StopService is invoked. So after you press Start service, after running the Android Apidemo sample resolution: App->service->remote Service Binding to bind this remoteservice, Since Remoteservice has started, you will find that the initial value of the received from service in example 42 is generally not 1.

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.