Last active
July 11, 2020 07:52
-
-
Save MrCrambo/6dee10a649ca3b959c37216d916640cf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void setMock(String provider, double latitude, double longitude) { | |
mLocationManager.addTestProvider (provider, false, false, false, false, false, true, true, 0, 5); | |
Location newLocation = new Location(provider); | |
newLocation.setLatitude(latitude); | |
newLocation.setLongitude(longitude); | |
newLocation.setAltitude(3F); | |
newLocation.setTime(System.currentTimeMillis()); | |
newLocation.setSpeed(0.01F); | |
newLocation.setBearing(1F); | |
newLocation.setAccuracy(3F); | |
newLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos()); | |
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) | |
{ | |
newLocation.setBearingAccuracyDegrees(0.1F); | |
newLocation.setVerticalAccuracyMeters(0.1F); | |
newLocation.setSpeedAccuracyMetersPerSecond(0.01F); | |
} | |
mLocationManager.setTestProviderEnabled(provider, true); | |
mLocationManager.setTestProviderLocation(provider, newLocation); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment