Apparently there are 2 ways of setting mock location in the Android ( currently playing with Android 11 )
One way using FusedLocationProviderClient:
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mFusedLocationClient.setMockMode(true);
mFusedLocationClient.setMockLocation(createLocation(LAT, LNG, ACCURACY));
Another using LocationManager:
LocationManager lm = (LocationManager) ctx.getSystemService(
Context.LOCATION_SERVICE);
lm.addTestProvider(providerName, false, false, false, false, false,
true, true, 1, 1);
lm.setTestProviderEnabled(providerName, true);
Location mockLocation = createLocation(LAT, LNG, ACCURACY);
lm.setTestProviderLocation(providerName, mockLocation);
Wondering what is the right way. For me second works fine, the first one in not ( still investigating ) But I wondering what is the RIGHT way? Also wondering why there are 2 distinct ways ?