【发布时间】:2018-12-14 15:30:32
【问题描述】:
像这样启动我的谷歌播放服务客户端:
public class MyApplication extends Application implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener
protected synchronized GoogleApiClient buildGoogleApiClient() {
return new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(LocationServices.API)
.build();
}
/* GoogleApiClient.ConnectionCallbacks */
@Override
public void onConnected(Bundle bundle) {
Log.v(TAG, "Google play services connected.");
boolean isConnected = mGoogleApiClient.isConnected(); // - this is true
boolean isLocAvailable = LocationServices.FusedLocationApi.getLocationAvailability(mGoogleApiClient).isLocationAvailable();
// this causes NullPointerException because getLocationAvailabality() returns null. WHY ????
.
.
.
}
}
Google Play 服务库版本为 Rev.24。 为什么会发生这种空指针接收? Google API 客户端已初始化,已连接,一切都按照文档应有的方式进行? WiFi 连接存在...
【问题讨论】:
标签: android google-play-services