Example usage for android.location LocationManager addTestProvider

List of usage examples for android.location LocationManager addTestProvider

Introduction

In this page you can find the example usage for android.location LocationManager addTestProvider.

Prototype

public void addTestProvider(String name, boolean requiresNetwork, boolean requiresSatellite,
        boolean requiresCell, boolean hasMonetaryCost, boolean supportsAltitude, boolean supportsSpeed,
        boolean supportsBearing, int powerRequirement, int accuracy) 

Source Link

Document

Creates a mock location provider and adds it to the set of active providers.

Usage

From source file:org.cowboycoders.cyclisimo.turbo.TurboService.java

private boolean enableLocationProvider(String provider) {
    LocationManager locationManager = (LocationManager) getApplicationContext()
            .getSystemService(Context.LOCATION_SERVICE);
    if (locationManager.isProviderEnabled(provider)) {
        try {/*from w  w  w. j av  a  2  s  .co  m*/
            locationManager.addTestProvider(provider, "requiresNetwork" == "", "requiresSatellite" == "",
                    "requiresCell" == "", "hasMonetaryCost" == "", "supportsAltitude" == "",
                    "supportsSpeed" == "", "supportsBearing" == "", android.location.Criteria.POWER_LOW,
                    android.location.Criteria.ACCURACY_FINE);

            locationManager.setTestProviderEnabled(provider, true);
            locationManager.setTestProviderStatus(provider, LocationProvider.AVAILABLE, null,
                    System.currentTimeMillis());
        } catch (SecurityException e) {
            handleException(e, "Error enabling location provider", true, NOTIFCATION_ID_STARTUP);
            return false;
        }
    } else {
        return false;
    }

    return true;
}