6

I have been playing with Service, but I cannot get them to run like I need. I need to call the Service functions from the Activity, and I use this

public class LocalBinder extends Binder {
    LocalService getService() {
        return LocalService.this;
    }
}

But how do I callback the Activity once a long network operation is done?

I want to show a spinner on the action bar while the service does something, and when it finishes to hide it. I also need it to persist on all different activities that have the same action bar.

Also, ServiceConnection is an asynchronous callback, so how do I bind to the service, wait for the callback and then change from case to case which function of the service to call?

Andrew T.
  • 4,701
  • 8
  • 43
  • 62
max4ever
  • 11,909
  • 13
  • 77
  • 115
  • Related: [Accessing UI thread handler from a Service](http://stackoverflow.com/questions/6369287/accessing-ui-thread-handler-from-a-service) – Andrew T. Dec 11 '15 at 22:34

1 Answers1

0

well , the call to the service's function is synchrounous , but the implementation of the function on the service can be asynchrounous (for example , using asyncTask ) and when the result is finished , you can either send an intent , or call a listener that was stored for the call .

android developer
  • 114,585
  • 152
  • 739
  • 1,270