Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
299 views
in Technique[技术] by (71.8m points)

android - `GPGGA` and `GPRMC` sentences are not received in onNmeaMessage

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...