Reputation: 285
How can I keep GoogleApiClient connected even if the app is killed ?
Actually, the connection to the API is handled in the Activity A. I pass an instance of the client to an Activity that extends Application. Then, I get the client instance in the Activity B. All works perfectly until the app is killed. When the app is launched, the client is null and the user is forced to re-connect to Google Fit...
What I want is like in Google Fit app, until the user does not use the disconnect option, the client is still connected and not null even if the app is killed.
Thanks a lot !
EDIT
After few search, I have to use Service to have a persistent connection to the Google Api but how can I pass the client to the service ?
Upvotes: 0
Views: 523
Reputation: 305
The best way is to run Google Fit in a service.
I have a scaffold project here that shows how that works.
https://github.com/rsteckler/Android-Google-Fit-Service-Skeleton
Upvotes: 2