Prevent GPS Spoofing
Posted By : Sapna Sharma | 19-May-2016
Before going to develop a location based app, it’s important to know that hackers can spoof their GPS location and illegally activate our app’s features.
As we know in Android system resources are shared across its applications. This is the basic difference from iOS environment where every app gets its own sandbox environment. So we need to take some extra measures.
To prevent our location based app from getting spoofed, we can check whether the location is coming from real provider or from a test/fake provider so that we can filter out fake locations.
With the below code we can check if the device enables Mock Locations and might be using a fake GPS app:
public boolean isMockLocationEnabled(Context context) {
if (Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"))
return false;
else
return true;
}
boolean isMock = false;
if (android.os.Build.VERSION.SDK_INT < 18) {
if (Settings.Secure.getString(currentActivity.getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION).equals("0"))
isMock = false;
else
isMock = true;
} else {
isMock = location.isFromMockProvider();
}
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Sapna Sharma
Sapna is a bright Android Apps developer using Titanium framework. Sapna likes music and helping needy people.