本文整理汇总了Java中android.location.GpsStatus.NmeaListener类的典型用法代码示例。如果您正苦于以下问题:Java NmeaListener类的具体用法?Java NmeaListener怎么用?Java NmeaListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NmeaListener类属于android.location.GpsStatus包,在下文中一共展示了NmeaListener类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: notifyNmeaSentence
import android.location.GpsStatus.NmeaListener; //导入依赖的package包/类
/**
* 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);
}
});
}
}
}
}
}
示例2: addNmeaListener
import android.location.GpsStatus.NmeaListener; //导入依赖的package包/类
/**
* 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;
}
示例3: removeNmeaListener
import android.location.GpsStatus.NmeaListener; //导入依赖的package包/类
/**
* 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);
}