Reputation: 201
I'm writing an app, that fakes my location. In order to do so, I need to fill in:
mylocation = new location;
mylocation.ElapsedRealTimeNanos = xxx;
So, I don't really know what is meant by that. In the guide, it says:
"elapsedRealtime() and elapsedRealtimeNanos() return the time since the system was booted, and include deep sleep. This clock is guaranteed to be monotonic, and continues to tick even when the CPU is in power saving modes, so is the recommend basis for general purpose interval timing. "
So, if I'm now trying to set a mock location, I cant just put this value to a constant, I'm pretty sure I need to put it to something, that give a correct value. But how do I get the real value for my mocked object?
Thanks:)
Upvotes: 2
Views: 228
Reputation: 74209
Example of mocking a location of downtown Seattle, WA, USA:
var mockLocation = new Location("SeattleMockedLocation")
{
Latitude = 47.60357f,
Longitude = -122.3295f,
Altitude = 0.0f,
Accuracy = 20.0f,
ElapsedRealtimeNanos = Java.Lang.JavaSystem.NanoTime(),
Time = Java.Lang.JavaSystem.CurrentTimeMillis()
};
Upvotes: 0