嗨我需要一些帮助,我已经看过并尝试许多不同的事情。我试图让我在android上的当前位置,但由于位置返回null我的应用程序崩溃。我真的需要这方面的帮助。谷歌地图v2 API的Android位置返回null
我不知道我是否在这里清楚,但每次我调用getLastKnownlocation它回来为空,所以当我尝试获得双lat = location.getLatitude()相同的经度它不会返回任何东西,并有我的应用程序崩溃的地方。
帮助...... 这里位于北纬一段代码
mMap.setMyLocationEnabled(true);
LocationManager locationManager = (LocationManager)getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
Location location = locationManager.getLastKnownLocation(provider);
mMap.setMapType(GoogleMap.MAP_TYPE_HYBRID);
double lat = location.getLatitude();
double lng = location.getLongitude();
LatLng latLng = new LatLng(lat, lng);
是它停止。
你得到的 字符串提供商提供什么= locationManager.getBestProvider(标准,真正的);? – CAA 2015-03-02 14:41:24
从来没有一个位置返回给你,所以你必须始终检查一个空位置 – tyczj 2015-03-02 14:56:40
@CAA我得到的提供商是这条线上的GPS – 2015-03-02 15:30:52