【发布时间】:2018-04-26 14:49:11
【问题描述】:
在片段onCreateview 中,连接GoogleAPIClient,但它不会触发onConnected 调用,但如果我转到另一个片段并返回,它会触发。
找不到原因?当我被卡住时,任何帮助将不胜感激?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mGoogleApiClient = new GoogleApiClient.Builder(getActivity())
.enableAutoManage(getActivity(), GOOGLE_API_CLIENT_ID, this)
.addConnectionCallbacks(this)
.addApi(LocationServices.API)
.addApi(Places.GEO_DATA_API)
.addApi(Places.PLACE_DETECTION_API)
.build();
mGoogleApiClient.connect();
}
@Override
public void onConnected(Bundle bundle) {
mPlaceArrayAdapter.setGoogleApiClient(mGoogleApiClient);
Log.i(LOG_TAG, "Google Places API connected.");
}
【问题讨论】:
标签: android android-fragments google-play-services