Google Api Client sometime NULL in onConnected

前端 未结 6 473
小蘑菇
小蘑菇 2021-01-03 23:51

I implement GoogleApiClient as bellow:

 mGoogleApiClient = new GoogleApiClient.Builder(this)
                .enableAutoManage(this, 0 /* client         


        
6条回答
  •  旧巷少年郎
    2021-01-04 00:48

    Documentation says: At any given time, only one auto-managed client is allowed per id. To reuse an id you must first call stopAutoManage(FragmentActivity) on the previous client.

    What I personally do is making a call to bellow method before I leave the activity, in which I am using the Google Api Client.

    private void stopAutoManage() {
        if (mGoogleApiClient != null)
            mGoogleApiClient.stopAutoManage(mActivity);
    }
    

提交回复
热议问题