Error in Fragment: “Already managing a GoogleApiClient with id 0”

后端 未结 10 1965
独厮守ぢ
独厮守ぢ 2020-12-13 08:16

Everything works right the first time, if you launch a second time you see this error:

FATAL EXCEPTION: main
Process         


        
10条回答
  •  旧时难觅i
    2020-12-13 08:51

    Try to use your mGoogleApiClient from your activity. if you have declared GoogleApiClient on your activity, then you can't re-declared on your fragment. instead, re-use variable in that activity from fragment

    mGoogleApiClientInFragment = ((Youractivityclass)getActivity()).mGoogleApiClient;
    

    replace YouractivityClass with your activity of your fragment, and make sure set your mGoogleApiClient field in your activity to public

提交回复
热议问题