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.
Generally speaking, sure, why not?
In principle, yes, but it would probably depend a bit on what “those methods” actually are.
There are multiple ways to do IPC in Android with services. AIDL is one. Putting a
Messengerin anIntentextra is another. They are not mutually contradictory, and there are other options as well.They call
bindService()with aServiceConnection, then use theBindersupplied through theServiceConnection‘sonServiceConnected()method.