【发布时间】:2011-09-26 14:33:53
【问题描述】:
我遇到了LocationManager 类的问题:
我想更新我在onCreate() 中的当前位置,该类是从MapActivity 扩展而来的:
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
MyLocationListener lcs = new MyLocationListener();
lcs.onLocationChanged(lm.getLastKnownLocation(LocationManager.GPS_PROVIDER));
而getLastKnownLocation() 返回位置但不准确,我想调用LocationManager.requestLocationUpdates(),它在onCreate() 中返回null:
LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
MyLocationListener lcs=new MyLocationListener();
lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, lcs);
谁能告诉我如何才能在我的onCreate() 中获得我的当前位置?
【问题讨论】: