Question

I am trying to have an application that runs as a service on android, other apps will be distributed that need to communicate with it.

It has been implemented as a Service and running client apps work fine when they are packaged within the same app.

However following http://developer.android.com/guide/developing/tools/aidl.html I am having problems making this work for client applications, in particular the line

"In your implementation of ServiceConnection.onServiceConnected(), you will receive an IBinder instance (called service). Call YourInterfaceName.Stub.asInterface((IBinder)service) to cast the returned parameter to YourInterface type."

Since the applications are distributed separately I dont have access to YourInterfaceName and copying it across to the client app definitely feels like "the wrong way"

If anyone could provide a pointer to documentation / a book / source code that would be very helpful, thanks

(and forgive the irony in my name, was a bit of an in joke)

Was it helpful?

Solution

The book "Pro Android 2" has a decent example on AIDL...

OTHER TIPS

You have to copy (or otherwise include, or rewrite with comparable functionality) the portion of the code that does the client end of the Binder IPC's into the client projects.

What exactly do the applications need to communicate to each other?

If it is data, then you can take a look at ContentProvider.

You could also share information through Intent.putExtra.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top