0
我想从服务中获取位置并返回null,我不知道可能是什么问题。这里我的示例代码如下。android locationlistener
public void onStart(Intent intent, int startId) {
super.onStart(intent, startId);
locListener = new GpsLocationListener();
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0,
locListener);
loc = locListener.getLocation();
showMessage("Service started");
if (loc != null) {
latitude = String.valueOf(loc.getLatitude());
longitude = String.valueOf(loc.getLongitude());
}
if (latitude != null && longitude != null) {
connectWebservice();
}
Log.i("trackmeservice", "service started");
}
这里我的loc是空的。任何帮助将非常感谢,
是什么GpsLocationListener以上?那是你自己的班级吗? – MikeIsrael
GpsLocationListener是我的类,它实现了LocationListener – user1138300