【发布时间】:2015-11-27 16:07:11
【问题描述】:
正如上面提到的,我使用了以下示例:The Beginner’s Guide to Location in 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,所以任何人都可以帮助我知道问题出在哪里?
【问题讨论】:
标签: android android-emulator android-location genymotion-gps android-gps