Add MockLocationDetector dependency via Gradle
masterTo use the library in your Android project, add the following dependency to your _gradle.build_ file:
compile 'com.inforoeste.mocklocationdetector:mock-location-detector:1.0.0'repository·master·Indexed 23 days ago
https://github.com/smarques84/mocklocationdetectorAn Android library for detecting if a device is using mock locations. It provides methods to determine if a specific Location object is from a mock provider via isLocationFromMockProvider, check for apps with ALLOW_MOCK_LOCATIONS permissions using checkForAllowMockLocationsApps, and check the system-wide 'Allow Mock Locations' setting.
To use the library in your Android project, add the following dependency to your _gradle.build_ file:
compile 'com.inforoeste.mocklocationdetector:mock-location-detector:1.0.0'Use isLocationFromMockProvider to determine if a received Location object was generated by a mock provider.
Behavior by API level:
This is the recommended method for most use cases.
Call checkForAllowMockLocationsApps to check if there are any applications installed on the user's device that have the ALLOW_MOCK_LOCATIONS permission declared in their manifest.
This is useful for detecting attempts to bypass location security on older devices (API 17 or lower) where root access might be used to manipulate mock location settings at runtime. Note that on Android Marshmallow (API 23) and above, it is no longer possible to enable/disable mock locations at runtime via root permissions.
The method isAllowMockLocationsOn checks if the system-wide 'Allow Mock Locations' setting is enabled.
Warning: This method is deprecated. On Android Marshmallow (API 23) and higher, this method will always return false.