安卓正则表达式外部 GPS 字符串



我在分隔从外部 GPS 流获得的字符串中的信息时遇到问题。

下面是一个字符串的示例:

$GPGSV,3,3,12,22,09,276,31,25,24,247,24,27,54,131,,32,04,359,19*71
$GPGLL,5703.85365,N,00953.88360,E,075510.00,A,A*69
$GPPWR,028a,1,0,1,1
$GPRMC,075511.00,A,5703.85369,N,00953.88430,E,0.335,302.17,070912,,,A*6E
$GPVTG,302.17,T,,M,0.335,N,0.621,K,A*3A

我想做的是把"$GPGLL,5703.85365,N,00953.88360,E,075510.00,A,A*69"拿出来,这样我就可以抓住长度和纬度,然后用它更新我的文本视图。但是继续从赏金中得到字符串,我开始怀疑我是否以错误的方式处理这个问题。

有谁能让我朝着如何解决这个问题的正确方向?

以下是直接从GPS处理NMEA句子的方法:

    // Listener for NMEA sentences
public void  onNmeaReceived(long timestamp, String nmea) {
            // Split the sentence into its comma-separated pieces
    String [] sentence = nmea.split(",");
            // See if it's the sentence we're interested in
    if(sentence[0].equalsIgnoreCase("$GPGLL")) {
    /* In here, process the data components of the sentence, which will
               be in sentence[1], sentence[2], etc. */
        }
    }
}

最新更新