6

I've been trying to get this to work for a few days without success. Basically, I'm writing a small test app to make the phone report it's position as somewhere else using addTestProvider and setTestProviderLocation etc. Basically it looks fine and appears to report its location as having changed, however Google Maps etc. seems to still be querying the real GPS provider. Does anyone have any ideas how to get around this?

This isn't an app that will actually be used for anything, it's just really to satisfy my own curiosity and gain an understanding.

Thanks in advance.

m0thman
  • 61
  • 1
  • 1
  • 2
  • 3
    If you manage this, it would make a great app for cheating husbands! – Fenton Jul 29 '10 at 14:03
  • 1
    there are already freely availably Location Spoofer application in the Market. – Pentium10 Jul 29 '10 at 14:25
  • Have you changed the phones system parameters to allow mock locations? Settings-Applications-Development-Allow mock locations? Not sure if that is your issue, but worth a shot. –  Aug 14 '10 at 13:11
  • Hi all - As it turns out switching from GPS to Network as a location provider solved the problem. Pentium10 - I know there's already apps out there. I was doing this to gain an understanding and because I wanted to get my code to work, not because I wanted to build a marketable app. I generally don't give up on an unsolved problem! – m0thman Aug 15 '10 at 10:00
  • 1
    What do you mean by "switching from GPS to Network as a location provider solved the problem"? Only the GPS location is faked? Or when you ask for both, both are correct? – Dirk Jäckel Aug 17 '12 at 06:21

1 Answers1

5

You need to first allow your application to use Mock locations by adding the following to the manifest xml:

<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"/>

On your phone, ensure 'Mock Locations' are enabled by selecting the “Allow mock locations” option under the Settings -> Applications -> Development menu.

And then use a mock location provider to give fake locations (e.g. by reading data off a file/db)

Alternatively you can telnet into your phone and mock the location (again you need permission and mock locations enabled on your phone):

$ telnet localhost 5554
Android Console: type 'help' for a list of commands
OK
geo fix -82.411629 28.054553
OK
Thira
  • 1,555
  • 1
  • 13
  • 24