當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。