2

Is it possible to use the same service on multiple activities and if so how?

casperOne
  • 73,706
  • 19
  • 184
  • 253
Sam
  • 6,215
  • 9
  • 71
  • 90

1 Answers1

2

You can use the onBind method in the service to connect to the service from multiple activities. If the Activitys are executed in the same process as the service you can use the local binder pattern

senola
  • 782
  • 4
  • 12
  • so i have to call the bindService (Intent service, ServiceConnection conn, int flags) method in each activity and pass the service connection object, my question is how can i have a common place to do all the service binding and unbinding? which activity i have to use for bind the service – Sam Jun 23 '11 at 06:48
  • 1
    if you are using the remote service in multiple activities i would suggest that you use the onResume and onPause methods within these activities for binding and unbinding using the current activity – senola Jun 24 '11 at 06:18