Search code examples
androidgoogle-play-servicesgoogle-api-clientsingleton-methods

Android: Is it possible to share a GoogleApiClient between activities and services?


Do every activity and service have to create their own GoogleApiClient and manage it with their onPause, onStop and connectivity issues? Is it possible to make an app client?

What I'm doing now is to copy and paste the same code in every activity or service. It works but I wonder if I am misunderstanding.

here is the code


Solution

  • It is possible you separate the GoogleApiClient concern from both Activity and Services, turning it into an observable model as shown in this Stack Overflow post, allowing one or many classes have access to it.