【发布时间】:2017-05-03 11:23:34
【问题描述】:
当构建 API 级别大于 23 的应用程序时,Google 地图未显示在棉花糖设备中,但它在棉花糖版本以下正确显示。我使用了 MapView。
实际上,我在 Marshmallow 中得到了 Current lat lang (0,0),这就是我在 marshmallow 中遇到问题的原因。为了获取当前的 lat lang,我正在使用这条线:-
private void getCurrentLatLong() {
try {
gps = new GPSTracker(getActivity());
if (gps.canGetLocation()) {
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
System.out.println("latitude print==" + latitude);
lat = String.valueOf(latitude);
lng = String.valueOf(longitude);
System.out.println("lat long check====" + "lati :" + lat + " -- lng :" + lng);
if (lat.equalsIgnoreCase("0.0") || lng.equalsIgnoreCase("0.0")) {
getCurrentLatLong();
} else {
mMapView.onResume();
setMap();
}
} else {
// can't get location
// GPS or Network is not enabled
// Ask user to enable GPS/network in settings
gps.showSettingsAlert();
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
【问题讨论】:
-
您介意展示您的代码吗?
-
如果发生错误,显示您的代码以及错误 logcat
-
@Luiz Fernando Salvaterra 实际上,当我构建高于 23 的应用程序时,我没有得到当前的纬度,它在棉花糖设备中总是 (0,0),但低于棉花糖它的工作正常
标签: android google-maps android-mapview