本文整理汇总了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);
}
}