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 =
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();
}