我在 Intent 服务中使用了 NmeaListener。
问题 - onNmeaReceived 永远不会被调用。
//This is a reference code
public class NMEAService extends IntentService {
private static NMEAListener listener;
// This function would be called from onHandleIntent
protected void getNMEA() {
listener = new NMEAListener();
LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 0,
listener,Looper.myLooper());
lm.addNmeaListener(listener);
}
private class NMEAListener implements NmeaListener{
@Override
public void onNmeaReceived(long timestamp, String nmea) {
// NMEA Received
// This is never getting called
}
@Override
public void onLocationChanged(Location location) {
// This is getting called
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
}
}
}