How to detect if the location is triggered with Mock Location in Android Marshmallow?
Previously, I used Settings.Secure.ALLOW_MOCK_L
This answer didn't seem to be work for me. extras.getBoolean(FusedLocationProviderApi.KEY_MOCK_LOCATION, false) always returned false.
However, I did this:
@Override
public void onLocationChanged (Location location){
boolean isMockLocation = location.isFromMockProvider();
}
and I started getting the correct results.