The Problem
I am working on the application which is listening for NMEA messages, to do so I am adding NMEA listener like this
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
TimeUnit.SECONDS.toMillis(1L),
0.0f,
new LocationListener() { /* Some code goes here*/ }
);
// ?? Adding NMEA LISTENER ??
locationManager.addNmeaListener(new OnNmeaMessageListener() {
@Override
public void onNmeaMessage(String nmea, long timestampMs) {
Log.d(TAG, "NMEA Message Received [" + timestampMs + "]: " + nmea);
}
}, new Handler(Looper.getMainLooper()));
I am only interested in the 2 types of NMEA sentences:
- GPGGA - Global Positioning System Fix Data
- GPRMC - Recommended minimum specific GPS/Transit data
but the issue is that when I am in the room (without or with bad GPS signal) I am receiving data like
$GPGGA,,,,,,0,,,,,,,,*66
$GPRMC,,V,,,,,,,,,,N,V*29
and when I am going outside (so GPS signal is strong), the method onNmeaMessage
stops receiving GPGGA
and GPRMC
sentences at all, it receives a lot of other sentences but not that two.
Question
Who can explain or give me a hint why with bad GPS signal I am receiving garbage date and with a strong GPS signal I am not receiving GPGGA
and GPRMC
sentences at all?
What should I do to constantly start listening for GPGGA
and GPRMC
sentences?
Device
- Pixel 3a XL
- Android 10
- With WiFI connected and 4G
Sourcecode
https://gist.github.com/ChamichApps/c0c85c5ccc87f159c7e1676dbe0d02ff
Notes
Interestingly that same source code is running on Samsung S10+ and I can see the GPGGA
and GPRMC
logs.
See Question&Answers more detail:
os