Skip to content

Instantly share code, notes, and snippets.

@newarifrh
Created February 2, 2020 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save newarifrh/910f34637c146b810f3e842fad2e0600 to your computer and use it in GitHub Desktop.
Save newarifrh/910f34637c146b810f3e842fad2e0600 to your computer and use it in GitHub Desktop.
public static boolean isMockLocationOn(Location location, Context context) {
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
return location.isFromMockProvider();
} else {
String mockLocation = "0";
try {
mockLocation = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION);
} catch (Exception e) {
e.printStackTrace();
}
return !mockLocation.equals("0");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment