0

I am facing this kind of problem: I have a remote (different process) bound service which defines an IntentFilter with action String. My client binds to it using the same action String in its bindService(..) call.

Now when I implement another service with completely different AIDL interface but with the same IntentFilter defined, install this service and remove the old one:

  1. my client is still able to bind
  2. my client is even able to call the desired method (say void print(Payload)) the client side does not complain, nor the server side

My question: is there a way how to check at runtime the interface the remote service is implementing?

The only possible way I've found is to check the ComponentName in the ServiceConnection. This has however one implication: I will not be able to exchange the implementation of the service in the future.

Or am I missing something?

Richard J. Ross III
  • 55,009
  • 24
  • 135
  • 201

1 Answers1

0

As I understand you want to do one of two things:

a) Connect to a service which implements required interface (and you don't care how the service is implemented)

In this case, you use intent filters. And in such case, each service should have different internt filter. Generally speaking, when you are defining the same intent filter you are saying that these two services are compatible (and they aren't, because of different AIDL's).

So, you should have different intent filters here.

b) Connect to a very particular service (It's not substitutable by any other service).

In such case, when you do bindService, you should specify expilicit component name in the intent, which you pass to bindService.

Victor Ronin
  • 22,758
  • 18
  • 92
  • 184
  • Thanks for your answer. What I originally wanted was: I’m going to supply some client application and a default implementation of the service (say PrintService). Then I would like to let a 3rd party to supply their own implementation of the service (same AIDL). By using – Jan Peremský Sep 19 '12 at 08:12