Reputation: 33771
I'm trying to expose methods using my subclass of Binder. I'm gonna have my Service return that Binder, etc, etc...
My question is: can I have my Binder implementation call methods defined in my other classes. As an example, I'm using XMPP to connect, login, and send chat messages. If I define those methods in a different class (which makes sense from a modularity perspective), can I simply expose them through my Binder?
Also, my understanding is that you no longer need to use AIDL for IPC (http://developer.android.com/guide/topics/fundamentals/bound-services.html#Messenger), but instead you can use messengers. I'm a bit unclear as to how an activity (or other app component) would bind and then make a call to a specific method exposed by my Binder.
Any samples or just setting me straight would be greatly appreciated.
Thanks.
Upvotes: 0
Views: 1232
Reputation: 1007554
My question is: can I have my Binder implementation call methods defined in my other classes.
Generally speaking, sure, why not?
If I define those methods in a different class (which makes sense from a modularity perspective), can I simply expose them through my Binder?
In principle, yes, but it would probably depend a bit on what "those methods" actually are.
Also, my understanding is that you no longer need to use AIDL for IPC (http://developer.android.com/guide/topics/fundamentals/bound-services.html#Messenger), but instead you can use messengers.
There are multiple ways to do IPC in Android with services. AIDL is one. Putting a Messenger
in an Intent
extra is another. They are not mutually contradictory, and there are other options as well.
I'm a bit unclear as to how an activity (or other app component) would bind and then make a call to a specific method exposed by my Binder.
They call bindService()
with a ServiceConnection
, then use the Binder
supplied through the ServiceConnection
's onServiceConnected()
method.
Upvotes: 2