Excerpt from Google API Client documentation,
public GoogleApiClient.Builder enableAutoManage (FragmentActivity
fragmentActivity, GoogleApiClient.OnConnectionFailedListener
unresolvedConnectionFailedListener)
Enables automatic lifecycle management in a support library FragmentActivity that connects the client in onStart() and disconnects it in onStop().
It handles user recoverable errors appropriately and calls onConnectionFailed(ConnectionResult) on the unresolvedConnectionFailedListener if the ConnectionResult has no resolution. This eliminates most of the boiler plate associated with using GoogleApiClient.
While it may sound a bit naive, but my question is if this is an important step that we start the connection of a GoogleAPIClient in onStart
method? Is there any harm if I make a connection in onCreate
instead? I have multiple scenarios where I see the need to connect to the googleApiClient in onCreate
due to the legacy code. I have also tried making a connection in onCreate and that works(I dont see any crashes). Is that a bad idea? So why is it necessary or important to start a connection in onStart
and stop the connection in onStop
?