正如上面提到的,我使用了以下示例:Android 中的初学者指南在我的代码中我放置了一个标签,以便在连接失败时打印一条错误消息,如下所述:
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
Log.i(TAG, "Location services Failed to connect. Please reconnect.");
}
每当我的应用程序连接到 google play 服务时,都会调用此方法。虽然我希望调用 onConnected 方法
@Override
public void onConnected(Bundle bundle) {
Log.i(TAG, "Location services connected.");
currentLocation = LocationServices.FusedLocationApi.getLastLocation(
mGoogleApiClient);
Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if(location== null)
{
}
else
{
handleNewLocation(location);
if (currentLocation != null) {
display.setText("Latitude: "+ String.valueOf(currentLocation.getLatitude())+"Longitude: "+
String.valueOf(currentLocation.getLongitude()));
}
}
}
另外我想添加更多内容,我的Genymotion VM中已经安装了google play服务,但是我无法进入play store,所以任何人都可以帮助我知道问题出在哪里?