當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.setExtras方法代碼示例

本文整理匯總了Java中android.location.Location.setExtras方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.setExtras方法的具體用法?Java Location.setExtras怎麽用?Java Location.setExtras使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.location.Location的用法示例。


在下文中一共展示了Location.setExtras方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toSysLocation

import android.location.Location; //導入方法依賴的package包/類
public Location toSysLocation() {
    Location location = new Location(LocationManager.GPS_PROVIDER);
    location.setAccuracy(8f);
    Bundle extraBundle = new Bundle();
    location.setBearing(bearing);
    Reflect.on(location).call("setIsFromMockProvider", false);
    location.setLatitude(latitude);
    location.setLongitude(longitude);
    location.setSpeed(speed);
    location.setTime(System.currentTimeMillis());
    location.setExtras(extraBundle);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        location.setElapsedRealtimeNanos(277000000);
    }
    int svCount = VirtualGPSSatalines.get().getSvCount();
    extraBundle.putInt("satellites", svCount);
    extraBundle.putInt("satellitesvalue", svCount);
    return location;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:20,代碼來源:VLocation.java

示例2: result

import android.location.Location; //導入方法依賴的package包/類
public Location result() {
    if (count < 1)
        return null;

    final Location location = new Location(BackendService.LOCATION_PROVIDER);

    location.setTime(timeMs);
    if (Build.VERSION.SDK_INT >= 17)
        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());

    location.setLatitude(meanLat);
    location.setLongitude(meanLon);
    if (count == 1) {
        location.setAccuracy(reportAccuracy);
    } else {
        //double varLat = sLat / (wSumLat - 1);
        //double varLon = sLon / (wSumLon - 1);
        double varLat = sLat / (wSumLat - wSum2Lat / wSumLat);
        double varLon = sLon / (wSumLon - wSum2Lon / wSumLon);

        double sdLat = Math.sqrt(varLat);
        double sdLon = Math.sqrt(varLon);

        //Log.d(TAG, "result() sLat=" + sLat + ", wSumLat=" + wSumLat + ", wSum2Lat=" + wSum2Lat + ", varLat=" + varLat + ", sdLat=" + sdLat);

        double sdMetersLat = sdLat * BackendService.DEG_TO_METER;
        double cosLat = Math.max(BackendService.MIN_COS, Math.cos(Math.toRadians(meanLat)));
        double sdMetersLon = sdLon * BackendService.DEG_TO_METER * cosLat;

        float acc = (float) Math.max(sdMetersLat, sdMetersLon);
        location.setAccuracy(acc);
    }

    Bundle extras = new Bundle();
    extras.putLong("AVERAGED_OF", count);
    location.setExtras(extras);

    return location;
}
 
開發者ID:n76,項目名稱:DejaVu,代碼行數:40,代碼來源:WeightedAverage.java

示例3: getLocation

import android.location.Location; //導入方法依賴的package包/類
public synchronized Location getLocation() {
    Long timeMs = System.currentTimeMillis();
    final Location location = new Location(BackendService.LOCATION_PROVIDER);

    predict(timeMs);
    location.setTime(timeMs);
    if (Build.VERSION.SDK_INT >= 17)
        location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
    location.setLatitude(mLatTracker.getPosition());
    location.setLongitude(mLonTracker.getPosition());
    if (mAltTracker != null)
        location.setAltitude(mAltTracker.getPosition());

    float accuracy = (float) (mLatTracker.getAccuracy() * BackendService.DEG_TO_METER);
    if (accuracy < MIN_ACCURACY)
        accuracy = MIN_ACCURACY;
    location.setAccuracy(accuracy);

    // Derive speed from degrees/ms in lat and lon
    double latVeolocity = mLatTracker.getVelocity() * BackendService.DEG_TO_METER;
    double lonVeolocity = mLonTracker.getVelocity() * BackendService.DEG_TO_METER *
            Math.cos(Math.toRadians(location.getLatitude()));
    float speed = (float) Math.sqrt((latVeolocity*latVeolocity)+(lonVeolocity*lonVeolocity));
    location.setSpeed(speed);

    // Compute bearing only if we are moving. Report old bearing
    // if we are below our threshold for moving.
    if (speed > MOVING_THRESHOLD) {
        mBearing = (float) Math.toDegrees(Math.atan2(latVeolocity, lonVeolocity));
    }
    location.setBearing(mBearing);

    Bundle extras = new Bundle();
    extras.putLong("AVERAGED_OF", samples);
    location.setExtras(extras);

    return location;
}
 
開發者ID:n76,項目名稱:DejaVu,代碼行數:39,代碼來源:Kalman.java


注:本文中的android.location.Location.setExtras方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。