开发者

Spoof or fake location on Android phone

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 aro开发者_运维问答und 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.


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜