Fatal Exception: java.lang.IllegalStateException GoogleApiClient is not connected yet

后端 未结 4 658
轮回少年
轮回少年 2020-12-10 11:16

We have this crash in crashlytics, the weird thing is it happens in onConnected() callback when requesting location updates.

Code:

4条回答
  •  再見小時候
    2020-12-10 11:40

    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.

提交回复
热议问题