using enableAutoManage() in fragment

后端 未结 4 375
说谎
说谎 2020-11-29 05:04

Is there another way to connect Google API client?

I use auto complete places and I have to use this code some where in MYFRAGMENT

mGoogleApiClient =         


        
4条回答
  •  失恋的感觉
    2020-11-29 05:44

    My solution is similar to accepted answer except, I use second signature of Builder so that connectionFailedListener is also send to the constructor.

    Followed by mGoogleApiClient.connect() and mGoogleApiClient.disconnect() in onStart() and onStop() respectively

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mGoogleApiClient = new GoogleApiClient.Builder(this /*context*/ , this /*connectedListener*/, this /**connectionFailedListener/)
                .addApi(Places.GEO_DATA_API)
                .build();
    }
    

提交回复
热议问题