I want to test a GPS application I am developing in my android tablet, so I need to send to it spoof locations from a KML file loading it using DDMS. I want to use a physical device, not the emulator.
The problem is that the Emulator Control section in DDMS is disabled (grayed out) when I select my external device (the app process running) in the devices view. Insted if I select the emulator then the emulator control appears enabled but not with the physical device.
My applicaton has
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
And my physical tablet is configured with:
- USB debugging.
- Allow mock locations
I'm using SDK r20 and my tablet has android 4.0.3.
Any ideas?
Thank you very much
For simple
spoofing
you can use this free version but as you said in your question you wantspoof
locations from aKML
file for that you have to buy pro versionI've pieced together a solution to this problem.
Go to Settings->Applications->Development and select "Allow mock locations".
Add ACCESS_MOCK_LOCATION permission to AndroidManifest.xml:
Implement a class which uses the LocationManager.addTestProvider() function. This will indicate to the application that it should use data from a file to construct new Location objects.
New Locations can then be created using the LocationManager.setTestProviderLocation() function.
Note: It is not possible to send mock locations to a real device from DDMS->Emulator Control->Location Controls regardless of device or manifest permissions as is incorrectly suggested here.
Sources:
Android mock location on device? - information about manifest permissions and alternative solution using the telnet command line, links and code snippets.
Using Mock Locations in Android - more verbose, contains some dead links.
LocationManager Documentation - Official Android documentation