Example usage for android.location Criteria ACCURACY_HIGH

List of usage examples for android.location Criteria ACCURACY_HIGH

Introduction

In this page you can find the example usage for android.location Criteria ACCURACY_HIGH.

Prototype

int ACCURACY_HIGH

To view the source code for android.location Criteria ACCURACY_HIGH.

Click Source Link

Document

a constant indicating a high accuracy requirement - may be used for horizontal, altitude, speed or bearing accuracy.

Usage

From source file:name.gumartinm.weather.information.activity.MapActivity.java

public void onClickGetLocation(final View v) {
    // TODO: Somehow I should show a progress dialog.
    // If Google Play Services is available
    if (this.mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        // TODO: Hopefully there will be results even if location did not change...   
        final Criteria criteria = new Criteria();
        criteria.setAccuracy(Criteria.ACCURACY_FINE);
        criteria.setAltitudeRequired(false);
        criteria.setBearingAccuracy(Criteria.NO_REQUIREMENT);
        criteria.setBearingRequired(false);
        criteria.setCostAllowed(false);//w w w  .  j a  v a 2 s  .  c om
        criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
        criteria.setPowerRequirement(Criteria.POWER_MEDIUM);
        criteria.setSpeedAccuracy(Criteria.NO_REQUIREMENT);
        criteria.setSpeedRequired(false);
        criteria.setVerticalAccuracy(Criteria.ACCURACY_HIGH);

        this.mLocationManager.requestSingleUpdate(criteria, this, null);
    } else {
        Toast.makeText(this, this.getString(R.string.weather_map_not_enabled_location), Toast.LENGTH_LONG)
                .show();
    }
    // Trying to use the synchronous calls. Problems: mGoogleApiClient read/store from different threads.
    // new GetLocationTask(this).execute();
}

From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java

/**
    * Translates a number representing desired accuracy of GeoLocation system from set [0, 10, 100, 1000].
    * 0:  most aggressive, most accurate, worst battery drain
    * 1000:  least aggressive, least accurate, best for battery.
    *//*from   w  w  w .  j  av a  2  s .co  m*/
    private Integer translateDesiredAccuracy(Integer accuracy) {
        switch (accuracy) {
        case 1000:
            accuracy = Criteria.ACCURACY_LOW;
            break;
        case 100:
            accuracy = Criteria.ACCURACY_MEDIUM;
            break;
        case 10:
            accuracy = Criteria.ACCURACY_HIGH;
            break;
        case 0:
            accuracy = Criteria.ACCURACY_HIGH;
            break;
        default:
            accuracy = Criteria.ACCURACY_MEDIUM;
        }
        return accuracy;
    }

From source file:com.marianhello.cordova.bgloc.LocationUpdateService.java

/**
    * TODO Experimental cell-tower change system; something like ios significant changes.
    *///www.java  2  s .  c  o  m
    public void onCellLocationChange(CellLocation cellLocation) {
        Log.i(TAG, "- onCellLocationChange" + cellLocation.toString());
        if (isDebugging) {
            Toast.makeText(this, "Cellular location change", Toast.LENGTH_LONG).show();
            startTone("chirp_chirp_chirp");
        }
        if (!isMoving && stationaryLocation != null) {
            criteria.setAccuracy(Criteria.ACCURACY_FINE);
            criteria.setHorizontalAccuracy(Criteria.ACCURACY_HIGH);
            criteria.setPowerRequirement(Criteria.POWER_HIGH);
            locationManager.requestSingleUpdate(criteria, singleUpdatePI);
        }
    }