O'Reilly logo

Learning Android by Marko Gargenta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Implementing the Remote Client

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:

  1. After you have created your LogClient project, right-click on your project in Package Explorer and choose Properties.

  2. In the “Properties for LogClient” dialog box, choose Java Build Path, and then click on the Projects tab.

  3. In this tab, click on “Add…”, and point to your LogService project.

This procedure will add LogService as a dependent project for LogClient.

Binding to the Remote Service

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required