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


Java Location.getElapsedRealtimeNanos方法代码示例

本文整理汇总了Java中android.location.Location.getElapsedRealtimeNanos方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getElapsedRealtimeNanos方法的具体用法?Java Location.getElapsedRealtimeNanos怎么用?Java Location.getElapsedRealtimeNanos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Location的用法示例。


在下文中一共展示了Location.getElapsedRealtimeNanos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getBestLastKnownLocation

import android.location.Location; //导入方法依赖的package包/类
/**
 * Restituice la posizione più accurata e più recente del dispositivo, scelta tra tutti i location provider disponibili.
 */
public static Location getBestLastKnownLocation(Context context) {
    LocationManager locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
    List<String> providers = locationManager.getAllProviders();
    Location bestLocation = null;

    for (String provider : providers) {
        try {
            Location location = locationManager.getLastKnownLocation(provider);
            if (bestLocation == null || location != null
                    && location.getElapsedRealtimeNanos() > bestLocation.getElapsedRealtimeNanos()
                    && location.getAccuracy() > bestLocation.getAccuracy())
                bestLocation = location;
        } catch (SecurityException ignored) {
        }
    }

    return bestLocation;
}
 
开发者ID:gvinciguerra,项目名称:custode,代码行数:22,代码来源:LocationService.java

示例2: onLocationChanged

import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location loc) {

    if (Logger.DEBUG) { Log.d(TAG, "[location changed: " + loc + "]"); }

    if (!skipLocation(loc)) {

        lastLocation = loc;
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
            lastUpdateRealtime = SystemClock.elapsedRealtime();
        } else {
            lastUpdateRealtime = loc.getElapsedRealtimeNanos() / 1000000;
        }
        db.writeLocation(loc);
        sendBroadcast(BROADCAST_LOCATION_UPDATED);
        if (liveSync) {
            startService(syncIntent);
        }
    }
}
 
开发者ID:bfabiszewski,项目名称:ulogger-android,代码行数:21,代码来源:LoggerService.java

示例3: getAge

import android.location.Location; //导入方法依赖的package包/类
/**
 * @param loc location object
 * @return age of event in ns
 */
public static Long getAge(Location loc) {
    if (loc == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
        return SystemClock.elapsedRealtimeNanos() - loc.getElapsedRealtimeNanos();
    } else {
        return (System.currentTimeMillis() - loc.getTime()) * 1000000L;
    }
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:15,代码来源:Helperfunctions.java


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