Java 类android.location.GpsStatus.NmeaListener 实例源码
项目:bluegnss4osm
文件:BluetoothGnssManager.java
/**
* Notifies the reception of a NMEA sentence from the bluetooth GPS to registered NMEA listeners.
*
* @param nmeaSentence the complete NMEA sentence received from the bluetooth GPS (i.e. $....*XY where XY is the checksum)
*/
private void notifyNmeaSentence(final String nmeaSentence){
if (enabled){
// Log.v(LOG_TAG, "parsing and notifying NMEA sentence: "+nmeaSentence);
String sentence = null;
try {
sentence = parser.parseNmeaSentence(nmeaSentence);
} catch (SecurityException e){
Log.e(LOG_TAG, "error while parsing NMEA sentence: "+nmeaSentence, e);
// a priori Mock Location is disabled
sentence = null;
disable(R.string.msg_mock_location_disabled);
}
final String recognizedSentence = sentence;
final long timestamp = System.currentTimeMillis();
if (recognizedSentence != null){
Log.v(LOG_TAG, "notifying NMEA sentence: "+recognizedSentence);
synchronized(nmeaListeners) {
for(final NmeaListener listener : nmeaListeners){
notificationPool.execute(new Runnable(){
@Override
public void run() {
listener.onNmeaReceived(timestamp, recognizedSentence);
}
});
}
}
}
}
}
项目:bluegnss4osm
文件:BluetoothGnssManager.java
/**
* Adds a NMEA listener.
* In fact, it delegates to the NMEA parser.
*
* @see NmeaParser#addNmeaListener(NmeaListener)
* @param listener a {@link NmeaListener} object to register
* @return true if the listener was successfully added
*/
public boolean addNmeaListener(NmeaListener listener){
if (!nmeaListeners.contains(listener)){
Log.d(LOG_TAG, "adding new NMEA listener");
nmeaListeners.add(listener);
}
return true;
}
项目:bluegnss4osm
文件:BluetoothGnssManager.java
/**
* Removes a NMEA listener.
* In fact, it delegates to the NMEA parser.
*
* @see NmeaParser#removeNmeaListener(NmeaListener)
* @param listener a {@link NmeaListener} object to remove
*/
public void removeNmeaListener(NmeaListener listener){
Log.d(LOG_TAG, "removing NMEA listener");
nmeaListeners.remove(listener);
}