【发布时间】:2011-02-12 06:13:57
【问题描述】:
我用几行代码将我的问题挑出来
lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000L, 5.0f, this);
lat = location.getLatitude();
lng = location.getLongitude();
//lat = new Double(40.431682);
//lng = new Double(-74.2021819);
pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000));
如果您想知道,我的 onLocationChanged
public void onLocationChanged(Location location) {
if (location != null) {
lat = location.getLatitude();
lng = location.getLongitude();
pLocation = new GeoPoint((int)(lat * 1000000), (int)(lng * 1000000));
}
}
如果我尝试获取 LastKnownLocation,我的应用程序会崩溃
但如果我手动输入位置,它会正常工作
我现在不知道出了什么问题
【问题讨论】:
标签: java android gps location locationmanager