$GPGGA,013810.000,1437.9098,N,12100.2297,E,1,10,1.0,26.4,M,39.1,M,,0000*69
$GPRMC,013810.000,A,1437.9098,N,12100.2297,E,0.00,122.34,200916,,,A*6A
$GPGGA,013811.000,1437.9098,N,12100.2297,E,1,10,1.0,26.4,M,39.1,M,,0000*69
$GPRMC,013811.000,A,1437.9098,N,12100.2297,E,0.00,122.34,200916,,,A*6A
$GPGGA,013812.000,1437.9098,N,12100.2297,E,1,10,1.0,26.4,M,39.1,M,,0000*69
$GPRMC,013812.000,A,1437.9098,N,12100.2297,E,0.00,122.34,200916,,,A*6A
每秒我将NMEA的字符串连接到字符串变量。我想要的是获得最后的$ GPGGA和GPRMC,因为我需要时间和日期。有没有办法做到这一点?先谢谢你们。
答案 0 :(得分:0)
如果您有以下内容:
String a = "$GPGGA,013812.000,1437.9098,N,12100.2297,E,1,10,1.0,26.4,M,39.1,M,,0000*69";
String b = "$GPRMC,013812.000,A,1437.9098,N,12100.2297,E,0.00,122.34,200916,,,A*6A";
然后在“,”符号处分开:
String[] aAry = a.split(",");
String[] bAry = b.split(",");
我认为每个数组的第二个元素(索引1)包含时间,因此它可以作为aAry[1]
访问,其中包含字符串013812.000(和bAry[1]
一样)。我不确定这些字符串中存储日期的位置。