How can I fake a (new) current location for the map?
Reason for NOT using the MOCKUP_SERVICE anymore is (1) errors in Android Studio Lollipot environment and (2) making it more flexibel.
Step 1: Write the following fake LocationProvider. You can use your own GPS class for giving for example the last location.
class MyMockupGpsMyLocationProvider implements IMyLocationProvider {
IMyLocationConsumer listener = null;
Location newLoc = GPS.getLastKnownLocation(); // or other class
public boolean startLocationProvider(IMyLocationConsumer var1) {
listener = var1;
return true;
}
public void stopLocationProvider() { }
public Location getLastKnownLocation() {
return GPS.getLastKnownLocation(); // or other class
}
public void updateLocation( Location newLoc) {
listener.onLocationChanged( newLoc, (IMyLocationProvider) this);
}
}
Step 2: Attach it to your MyOverlay
MyMockupGpsMyLocationProvider fakeGpsLocations = new MyMockupGpsMyLocationProvider();
myLocationOverlay.enableMyLocation(fakeGpsLocations );
Step 3: provide fake GPS locations. Here by calling the updateLocation().
mockupGpsPrivder.updateLocation(currentLocation);