【发布时间】:2017-03-14 13:35:26
【问题描述】:
我有一个谷歌地图。在模拟器中,一切正常,但在 android 设备中永远找不到当前位置(显示消息位置错误 - 请参阅代码)。地图以世界视图打开...
cnt = new MapContainer(new GoogleMapsProvider(""));
cnt.setMapType(MAP_TYPE_TERRAIN);
LocationManager locationManager = LocationManager.getLocationManager();
InfiniteProgress ip = new InfiniteProgress();
Dialog ipDlg = ip.showInifiniteBlocking();
Location loc = LocationManager.getLocationManager().getCurrentLocationSync(30000);
ipDlg.dispose();
if (loc == null) {
try {
loc = LocationManager.getLocationManager().getCurrentLocation();
} catch (IOException err) {
Dialog.show("Location Error", "Unable to find your current location, please be sure that your GPS is turned on", "OK", null);
return;
}
}
locationManager.setLocationListener(this);
if (loc != null) {
double lat = loc.getLatitude();
double lng = loc.getLongitude();
Coord coordinate = new Coord(lat, lng);
}
设备上的 GPS 处于活动状态。 我可以在其他应用中查看我的位置。
【问题讨论】:
标签: java codenameone