Example usage for android.location Criteria ACCURACY_LOW

List of usage examples for android.location Criteria ACCURACY_LOW

Introduction

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

Prototype

int ACCURACY_LOW

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

Click Source Link

Document

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

Usage

From source file:com.jeremy.tripcord.main.TripcordFragment.java

private CameraUpdate getLastKnownLocation() {
    LocationManager lm = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_LOW);
    String provider = lm.getBestProvider(criteria, true);
    if (provider == null) {
        return null;
    }//from w  ww  .j a  v  a 2  s.  c om
    Location loc = lm.getLastKnownLocation(provider);
    if (loc != null) {
        return CameraUpdateFactory.newCameraPosition(
                CameraPosition.fromLatLngZoom(new LatLng(loc.getLatitude(), loc.getLongitude()), 14.0f));
    }
    return null;
}

From source file:net.frakbot.FWeather.util.LocationHelper.java

/**
 * Returns the default criteria set for the LocationManager.
 * @return the default Criteria/*from w  w w.ja  va  2s. c om*/
 */
private static Criteria getDefaultCriteria() {
    Criteria criteria = new Criteria();
    criteria.setCostAllowed(false);
    criteria.setHorizontalAccuracy(Criteria.ACCURACY_LOW);
    criteria.setVerticalAccuracy(Criteria.NO_REQUIREMENT);
    criteria.setSpeedRequired(false);
    criteria.setPowerRequirement(Criteria.POWER_LOW);

    return criteria;
}

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.
    *//*ww  w.  jav  a  2  s . c o  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:fashiome.android.fragments.MapListFragment.java

private LatLng getLastKnownLocation(boolean isMoveMarker) {
    LocationManager lm = (LocationManager) AppStarter.getAppContext()
            .getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_LOW);
    String provider = lm.getBestProvider(criteria, true);
    if (provider == null) {
        return null;
    }//from   w w  w .jav a  2s .  c om
    Activity activity = getActivity();
    if (activity == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (activity.checkSelfPermission(
                Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && activity.checkSelfPermission(
                        Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return null;
        }
    }
    Location loc = lm.getLastKnownLocation(provider);
    if (loc != null) {
        LatLng latLng = new LatLng(loc.getLatitude(), loc.getLongitude());
        if (isMoveMarker) {
            moveMarker(latLng);
        }
        return latLng;
    }
    return null;
}

From source file:com.seatgeek.placesautocompletedemo.MainFragment.java

private LatLng getLastKnownLocation(boolean isMoveMarker) {
    LocationManager lm = (LocationManager) TheApp.getAppContext().getSystemService(Context.LOCATION_SERVICE);
    Criteria criteria = new Criteria();
    criteria.setAccuracy(Criteria.ACCURACY_LOW);
    String provider = lm.getBestProvider(criteria, true);
    if (provider == null) {
        return null;
    }/*from   w w  w .ja v a  2s  .c o  m*/
    Activity activity = getActivity();
    if (activity == null) {
        return null;
    }
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (activity.checkSelfPermission(
                Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED
                && activity.checkSelfPermission(
                        Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            return null;
        }
    }
    Location loc = lm.getLastKnownLocation(provider);
    if (loc != null) {
        LatLng latLng = new LatLng(loc.getLatitude(), loc.getLongitude());
        if (isMoveMarker) {
            moveMarker(latLng);
        }
        return latLng;
    }
    return null;
}