More than one activities require API client connection
Hi,
As recommended by Google, I was trying to connect to API client in onStart() and disconnect in onStop. However, the onStart() in Activity2 is called before the onStop() in Activity1, which causes the API client to be disconnected in Activity2.
I thought about simply not disconnecting API client in Activity1, but I'm worrying that if user kills the app in Activity1, would the API remain connected and end up causing memory issue or app crashing?
Is there a recommended way to resolve this issue?
"the onStart() in Activity2 is called before the onStop() in Activity1". Can you explain how this happens? I am a little confused.
I was referring to this page. Sorry, should have mentioned my question is regarding activity navigation. https://developer.android.com/guide/components/activities/activity-lifecycle.html#soafa
Should I only connect API client when needed instead of keeping it alive with the activity? Then what if I require continuous GPS updates in two different activities?