Now that we have the remote service, we are going to create a client that connects to that service to test that it all works well. Note that in this example we purposely separated the client and the server into two separate projects with different Java packages altogether, in order to demonstrate how they are separate apps.
So we’re going to create
a new Android project in Eclipse for this client, just as we’ve done
before for various other applications. However, this time around we are
also going to make this project depend on the
LogService project. This is important because
LogClient has to find the AIDL files we created as part of
LogService in order to know what that remote
interface looks like. To do this in Eclipse:
After you have created your
LogClient project, right-click on your
project in Package Explorer and choose Properties.
In the “Properties for LogClient” dialog box, choose Java Build Path, and then click on the Projects tab.
In this tab, click on “Add…”, and point to your
This procedure will add
LogService as a dependent project for
Our client is going to be an activity so that we can see it working graphically. In this activity, we’re going to bind to the remote service, and from that point on, use it as if it were just like any other local class. Behind the scenes, the Android binder will marshal and unmarshal the calls to the service.
The binding process is asynchronous, meaning ...