本文整理匯總了Java中com.nextgis.maplib.api.GpsEventListener類的典型用法代碼示例。如果您正苦於以下問題:Java GpsEventListener類的具體用法?Java GpsEventListener怎麽用?Java GpsEventListener使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GpsEventListener類屬於com.nextgis.maplib.api包,在下文中一共展示了GpsEventListener類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: addListener
import com.nextgis.maplib.api.GpsEventListener; //導入依賴的package包/類
/**
* Add new listener for GPS events. You will likely want to call addListener() from your
* Activity's or Fragment's onResume() method, to enable the features. Remember to call the
* corresponding removeListener() in your Activity's or Fragment's onPause() method, to prevent
* unnecessary use of the battery.
*
* @param listener
* A listener class implements GpsEventListener adding to listeners array
*/
public void addListener(GpsEventListener listener)
{
if (mListeners != null && !mListeners.contains(listener)) {
mListeners.add(listener);
if (mListeners.size() == 1) {
if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
|| !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
return;
requestUpdates();
mLocationManager.addGpsStatusListener(mGpsStatusListener);
}
}
}
示例2: removeListener
import com.nextgis.maplib.api.GpsEventListener; //導入依賴的package包/類
/**
* Remove listener from listeners of GPS events. You will likely want to call removeListener()
* from your Activity's or Fragment's onPause() method, to prevent unnecessary use of the
* battery. Remember to call the corresponding addListener() in your Activity's or Fragment's
* onResume() method.
*
* @param listener
* A listener class implements GpsEventListener removing from listeners array
*/
public void removeListener(GpsEventListener listener)
{
if (mListeners != null) {
mListeners.remove(listener);
if(!PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION)
|| !PermissionUtil.hasPermission(mContext, Manifest.permission.ACCESS_COARSE_LOCATION))
return;
if (mListeners.size() == 0) {
mLocationManager.removeUpdates(mGpsLocationListener);
mLocationManager.removeGpsStatusListener(mGpsStatusListener);
}
}
}
示例3: onGpsStatusChanged
import com.nextgis.maplib.api.GpsEventListener; //導入依賴的package包/類
@Override
public void onGpsStatusChanged(int event)
{
switch(event)
{
case GpsStatus.GPS_EVENT_STARTED:
case GpsStatus.GPS_EVENT_STOPPED:
mHasGPSFix = false;
break;
case GpsStatus.GPS_EVENT_FIRST_FIX:
mHasGPSFix = true;
break;
case GpsStatus.GPS_EVENT_SATELLITE_STATUS:
break;
}
for (GpsEventListener listener : mListeners) {
listener.onGpsStatusChanged(event);
}
}