Android local service binding - quick howto

So you've decided you need a Service in your Android app.
The question is how to invoke its methods? How to interact with it?

In a nutshell, you define an interface to the service.
Upon request of such an interface (by an activity), the code binds an asynchronous implementation of the interface to the real service and returns that implementation.
The activity invokes methods on that implementation (interface) and they are later (async) propagated to the service.
The result will be two toasts fired by the service, but originated from the activity.

Below is the how code.
When you test the code, don't forget to add the activity and service to the manifest file.
Enjoy!

Manifest:


Code:

Ubuntu 10.10 Eclipse Java sun source code

Motivation: Saw a lot of misleading instructions on how to attach Java source code in Eclipse on Ubuntu 10.10 and even how to install Java.

First of all, It is best to install Java on Ubuntu as described here.
(I wanted to link to another place but can't find it, so the commands were taken from my commands history)

The source code will be attached automatically.

Android SDK source to be viewed in Eclipse

EDIT: (2011/11/22)
It seems that after upgrading the SDK, the source folders were deleted.
I found a nice tool as an Eclipse plugin that attaches the source code.
The problem is that it currently supports only up to Android v2.3.4.
Or you can do it the manual way, as stated in my original post below.


Original post:
Attached are the sources to:


Reference:
Attaching sources to android.jar in Eclipse


Unzip them to the appropriate platform ander the android SDK folder.
android-sdk-2.1_r1 -> android-7
android-sdk-2.2_r2 -> android-8
android-2.3.3_r1a -> android-10

If you use api level 7 or 8, just restart eclipse and you should be able to view the source code (F3 on the Activity class :)

Hope it helps and you don't need to start messing with git, scripts, etc. - not that I'm against them, just thought of saving some time to other Android developers.

Also, I migrated the script from Mac to any other Linux. You can download it here.