2

I've developed an app that receives the location from both GPS_PROVIDER and NETWORK_PROVIDER, however the NETWORK_PROVIDER returns the best values retrieved from WIFI and GPRS, without having any control over it. I need to get the value returned by the GPRS location listener even when you have WIFI active, so I can use it to dismiss the fake locations from other apps. Is it possible to do this?

At the moment I'm testing this solution Disable / Check for Mock Location (prevent gps spoofing) , I'll let you know if it solves my issue

Community
  • 1
  • 1
TibiG
  • 819
  • 1
  • 6
  • 18
  • whts u getting error?? – GB_Bhayani ツ Jul 16 '14 at 11:54
  • There's not error, I just need both the location from WIFI and GPRS, so I can process them individually. I need to know if I can do this – TibiG Jul 16 '14 at 11:55
  • The spoofing detection works, however the "removeTestProvider(LocationManager.GPS_PROVIDER);" part of it doesn't work, at least on a Samsung GT-S5300 with 2.3.6 non-custom ROM on it. – TibiG Jul 18 '14 at 06:10

1 Answers1

0

Unfortunately it is not possible, no.

You can do something like this:

final LocationManager locationManager = getLocationManager();
final List<String> providers = locationManager.getProviders(true);
if (providers.size() > 1) {
  providers.remove(LocationManager.NETWORK_PROVIDER);
}

But you don't have the option to distinguish between a cell or a wifi network-provider!

This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup.

Constant Value: "network"

Source: http://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER

What you can try is to use this solution. However, since this doesn't seem to be documented I'd be careful relying on it because it might break in future OS versions or might not work on every device.

Community
  • 1
  • 1
Blacklight
  • 3,809
  • 2
  • 33
  • 39