0

外部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」を取り出して、長さと緯度を取得し、それを使用してテキストビューを更新できるようにすることです。しかし、文字列を束縛の例外から外し続けると、私はこれを間違った方法で処理しているかどうか疑問に思い始めます。

これを解決する方法で私を正しい方向に導くことができる人はいますか?

4

1 に答える 1

0

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. */
        }
    }
}
于 2012-09-22T21:35:13.390 に答える