Java Code Examples for android.location.Location#getVerticalAccuracyMeters()

The following examples show how to use android.location.Location#getVerticalAccuracyMeters() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GglMapLocationManager.java    From FimiX8-RE with MIT License 6 votes vote down vote up
public void onLocationChanged(Location location) {
    startMoveLocationAndMap(location);
    float verticalAccuracyMeter = 0.0f;
    if (VERSION.SDK_INT >= 26) {
        verticalAccuracyMeter = location.getVerticalAccuracyMeters();
    }
    X8PressureGpsInfo.getInstance().setmLongitude(location.getLongitude());
    X8PressureGpsInfo.getInstance().setmLatitude(location.getLatitude());
    X8PressureGpsInfo.getInstance().setmAltitude(location.getAltitude());
    X8PressureGpsInfo.getInstance().setmHorizontalAccuracyMeters(location.getAccuracy());
    X8PressureGpsInfo.getInstance().setmVerticalAccuracyMeters(verticalAccuracyMeter);
    X8PressureGpsInfo.getInstance().setmSpeed(location.getSpeed());
    X8PressureGpsInfo.getInstance().setmBearing(location.getBearing());
    X8PressureGpsInfo.getInstance().setHasLocation(true);
    this.accuracy = location.getAccuracy();
    getCityThread(location);
}
 
Example 2
Source File: GnssLocationProvider.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void injectBestLocation(Location location) {
    int gnssLocationFlags = LOCATION_HAS_LAT_LONG |
            (location.hasAltitude() ? LOCATION_HAS_ALTITUDE : 0) |
            (location.hasSpeed() ? LOCATION_HAS_SPEED : 0) |
            (location.hasBearing() ? LOCATION_HAS_BEARING : 0) |
            (location.hasAccuracy() ? LOCATION_HAS_HORIZONTAL_ACCURACY : 0) |
            (location.hasVerticalAccuracy() ? LOCATION_HAS_VERTICAL_ACCURACY : 0) |
            (location.hasSpeedAccuracy() ? LOCATION_HAS_SPEED_ACCURACY : 0) |
            (location.hasBearingAccuracy() ? LOCATION_HAS_BEARING_ACCURACY : 0);

    double latitudeDegrees = location.getLatitude();
    double longitudeDegrees = location.getLongitude();
    double altitudeMeters = location.getAltitude();
    float speedMetersPerSec = location.getSpeed();
    float bearingDegrees = location.getBearing();
    float horizontalAccuracyMeters = location.getAccuracy();
    float verticalAccuracyMeters = location.getVerticalAccuracyMeters();
    float speedAccuracyMetersPerSecond = location.getSpeedAccuracyMetersPerSecond();
    float bearingAccuracyDegrees = location.getBearingAccuracyDegrees();
    long timestamp = location.getTime();
    native_inject_best_location(gnssLocationFlags, latitudeDegrees, longitudeDegrees,
            altitudeMeters, speedMetersPerSec, bearingDegrees, horizontalAccuracyMeters,
            verticalAccuracyMeters, speedAccuracyMetersPerSecond, bearingAccuracyDegrees,
            timestamp);
}
 
Example 3
Source File: LocationEntity.java    From background_location_updates with Apache License 2.0 6 votes vote down vote up
public static LocationEntity fromAndroidLocation(Location location) {
    Double vAcc = null, cAcc = null, speedAcc = null;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
        vAcc = (double) location.getVerticalAccuracyMeters();
        cAcc = (double) location.getBearingAccuracyDegrees();
        speedAcc = (double) location.getSpeedAccuracyMetersPerSecond();
    }

    return new LocationEntity(
            (double) location.getAccuracy(),
            vAcc,
            location.getLongitude(),
            location.getLatitude(),
            location.getAltitude(),
            (double )location.getSpeed(),
            location.getTime(),
            0,
            (double) location.getBearing(),
            cAcc,
            speedAcc,
            location.getProvider()
    );
}
 
Example 4
Source File: ReplayJsonRouteLocationMapperTest.java    From graphhopper-navigation-android with MIT License 5 votes vote down vote up
@Test(expected = NoSuchMethodError.class)
@Config(sdk = 25)
public void checksVerticalAccuracyNotMappedForBelowOreo() {
  List<ReplayLocationDto> anyReplayLocations = new ArrayList<>(1);
  ReplayLocationDto aReplayLocation = new ReplayLocationDto();
  aReplayLocation.setVerticalAccuracyMeters(8.0f);
  anyReplayLocations.add(aReplayLocation);
  ReplayJsonRouteLocationMapper theReplayJsonRouteLocationMapper = new ReplayJsonRouteLocationMapper(anyReplayLocations);

  List<Location> locations = theReplayJsonRouteLocationMapper.toLocations();

  Location theLocation = locations.get(0);
  theLocation.getVerticalAccuracyMeters();
}
 
Example 5
Source File: OpenLocateLocation.java    From openlocate-android with MIT License 5 votes vote down vote up
LocationInfo(Location location) {
    latitude = location.getLatitude();
    longitude = location.getLongitude();
    horizontalAccuracy = location.getAccuracy();
    timeStampSecs = TimeUnit.MILLISECONDS.toSeconds(location.getTime());
    speed = location.getSpeed();
    course = location.getBearing();
    altitude = location.getAltitude();

    if (Build.VERSION.SDK_INT >= 26) {
        verticalAccuracy = location.getVerticalAccuracyMeters();
    }
}