Android Services: On-Demand Binding vs. #onCreate () Binding

We have a Service that takes care of several things in one of our actions. We are pretty new to Android and are wondering what is the ideal moment to bind to this service. We need only a service for half of the interactions that are possible through activity. Therefore, we must solve one of two possibilities:

  • binding to the Service when we really need it, which will add a sufficient amount of overhead
  • binding to the service in the onCreate () method without the overhead of checking if the service is working, tying it on demand, possibly made cache requests, etc.

What will be the "android" here? Is a running service a lot of overhead or should it be run only when necessary? The service itself is very light.

+5
source share
1 answer

bindService() onCreate(), , , unbindService() onDestroy(). - bindService() - . API. bindService(), , ServiceConnection.onServiceConnected(), , bindService() , , onCreate(), .

+1

All Articles