当前位置: 首页>>代码示例>>Java>>正文


Java GpsEventListener类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:25,代码来源:GpsEventSource.java

示例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);
        }
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:25,代码来源:GpsEventSource.java

示例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);
    }
}
 
开发者ID:nextgis,项目名称:android_maplib,代码行数:21,代码来源:GpsEventSource.java


注:本文中的com.nextgis.maplib.api.GpsEventListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。