我在LocationManager
课堂上面临一个问题:
我想在onCreate()
一个扩展自以下的类中更新我的当前位置MapActivity
:
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
MyLocationListener lcs = new MyLocationListener();
lcs.onLocationChanged(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER));
而返回位置但不准确,getLastKnownLocation()
我想调用LocationManager.requestLocationUpdates()
which 返回:null
onCreate()
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
MyLocationListener lcs=new MyLocationListener();
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, lcs);
谁能告诉我如何在我的 中获得我当前的位置onCreate()
?