This issue has come up a number of times before. What you need to do is to define another aidl interface that is a 'callback' interface that contains the methods that you want to go from your service to your activity. Add a 'registerCallback' method to your existent aidl interface which registers this interface as a call back from the service. You then implement this interface in your activity. Your service will need to have a RemoteCallbackList defined, so that the callback can be registered. In the sdk examples the 'remote service' sample is an example of how to do this. It does work, I have this working in several different applications now.
Add a reference for your callback interface in your service. Have an implentation of the callback in your activity. Add a registerCallback () method to your current interface that might look something like this in your service class: MyInterface.Stub cInterface = new MyInterface.Stub() { public void registerCallback(MyCallback callback) { System.out.println("Registering Callback: "+callback.toString()); my_service.this.mycallback=callback; mCallbacks.register(my_service.this.callback); System.out.println("Callback Registered:"); } where mycallback is reference to the callback implmentation and mCallbacks is a RemoteCallbackList. Check the 'remote service' example also to the full code. Mark On Nov 24, 7:50 am, G <ghack...@gmail.com> wrote: > After a long working weekend I finally have a grasp on how activities > bind to services (as well as how services outlive the activities that > started them). But it seems that through binding, the communication is > only 1-way (Activity -> Service). How can my service notify my > activity of something? Do I need to define a BroadcastReceiver and > sendBroadcast() from my service or is there an easier way to do it > while the Service and Activity are binded? > > (This is a Remote Service btw, and if you're going to tell me to use a > Handler, please please please include a link to a tutorial or some > good sample code, cause I can't seem to find any) > > Thanks in advance :) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---