GoogleApiClient is throwing “GoogleApiClient is not connected yet” AFTER onConnected function getting called

前端 未结 9 1623
-上瘾入骨i
-上瘾入骨i 2020-11-27 04:38

So I found something that is not very clear for me about GoogleApiClient. GoogleApiClient has a function called onConnected which is run wh

9条回答
  •  醉梦人生
    2020-11-27 05:38

    https://developer.android.com/reference/com/google/android/gms/common/api/GoogleApiClient.html

    You should instantiate a client object in your Activity's onCreate(Bundle) method and then call connect() in onStart() and disconnect() in onStop(), regardless of the state.

    The implementation of the GoogleApiClient appears designed for only a single instance. It's best to instantiate it only once in onCreate, then perform connections and disconnections using the single instance.

提交回复
热议问题