Code example for LocationManager

Methods: getProvidersetTestProviderLocation

0
         
        if(!doesDeviceProvideGPS()) { 
            return new Result(false, "This devices does not support GPS");
        } 
         
        LocationProvider currentGPSProvider = locationManager.getProvider(LocationManager.GPS_PROVIDER);
        addTestProvider(currentGPSProvider, LocationManager.GPS_PROVIDER);
             
        Location location = new Location(LocationManager.GPS_PROVIDER);
        location.setLatitude(Double.parseDouble(args[0]));
        location.setLongitude(Double.parseDouble(args[1]));
        location.setTime(System.currentTimeMillis());
        locationManager.setTestProviderLocation(LocationManager.GPS_PROVIDER, location);
         
        return Result.successResult(); 
    } 
 
    @Override 
    public String key() {
        return "set_gps_coordinates";