How to detect if the location is triggered with Mock Location in Android Marshmallow?
Previously, I used Settings.Secure.ALLOW_MOCK_L
If you are using FusedLocationProviderApi and have set mock location using setMockLocation(mGoogleApiClient, fakeLocation); in the callback/pendingIntentCallback the returned Location object contains KEY_MOCK_LOCATION extra, a boolean that indicates that received object is mock.
@Override
public void onLocationChanged (Location location){
Bundle extras = location.getExtras();
boolean isMockLocation = extras != null && extras.getBoolean(FusedLocationProviderApi.KEY_MOCK_LOCATION, false);
}