Example usage for android.location Location setElapsedRealtimeNanos

List of usage examples for android.location Location setElapsedRealtimeNanos

Introduction

In this page you can find the example usage for android.location Location setElapsedRealtimeNanos.

Prototype

public void setElapsedRealtimeNanos(long time) 

Source Link

Document

Set the time of this fix, in elapsed real-time since system boot.

Usage

From source file:Main.java

/**
 * Create a {@link Location} object from the speified latitude and longitude.
 * @param latitude the latitude for the location to create.
 * @param longitude the longitude for the location to create.
 * @return a {@link Location} object.//w w  w.  ja v  a2  s . c om
 */
public static Location createLocation(double latitude, double longitude) {
    Location location = new Location(LocationManager.NETWORK_PROVIDER);
    location.setLatitude(latitude);
    location.setLongitude(longitude);
    location.setAccuracy(10f);
    location.setTime(System.currentTimeMillis());
    location.setAltitude(0d);
    location.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
    return location;
}

From source file:com.kylemsguy.fishyfishes.MainActivity.java

public void sendLoc(double lat, double lon) {
    LocationServices.FusedLocationApi.setMockMode(mGoogleApiClient, true);
    Location loc = new Location("network");

    loc.setLatitude(lat);/* w  ww .  jav a 2s. com*/
    loc.setLongitude(lon);
    System.out.println(loc.toString());
    loc.setAccuracy(10);
    loc.setTime(System.currentTimeMillis());
    loc.setElapsedRealtimeNanos(1);
    LocationServices.FusedLocationApi.setMockLocation(mGoogleApiClient, loc);
}