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

后端 未结 4 656
轮回少年
轮回少年 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:46

    Maybe you should notice, GoogleApiClient.Builder has a method setAccountName(). You should invoke this method with your Google account name. I have tried, and succeeded. I used the following code:

    if (mGoogleApiClient == null) {
        mGoogleApiClient = new GoogleApiClient.Builder(context)
           .addApi(LocationServices.API)
           .addConnectionCallbacks(this)
           .addOnConnectionFailedListener(this)
           .setAccountName("李江涛")
           .build();
    }
    
    if (mLocationRequest == null) {
        mLocationRequest = new LocationRequest();
        mLocationRequest.setInterval(10000);
        mLocationRequest.setFastestInterval(5000);
        mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
    }
    

提交回复
热议问题