Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simulate Mock Location on Android Device via DDMS

I have a GPS navigation application for Android 2.3.3 which I have been working on. I am currently trying to simulate locations via a GPX file through DDMS. While this works perfectly find on the android emulator, I am unable to get it working on an actual device.

I am able to see the device on the under the "Devices" tab, but I am unable to send any mock location data, or GPX data as the options are under "Emulation Control" tab are grayed out.

I have noticed that previous questions on StackOverflow mention that it is not possible, however the Google docs titled "Using DDMS" - http://developer.android.com/tools/debugging/ddms.html state the following (at the bottom of the page)

Setting the location of the phone

If your application depends on the location of the phone, you can have DDMS send your device or AVD a mock location. This is useful if you want to test different aspects of your application's location specific features without physically moving. The following geolocation data types are available to you:

I am just wondering how to send fake location data to a device via DDMS. Thank you for your help in advance, and I really appreciate it.

like image 704
Bilzac Avatar asked Jul 16 '12 06:07

Bilzac


2 Answers

Bilzac, your understanding is correct. Simply put, Android's documentation is misleading. Many developers have been confused by this. You cannot load a gpx file and send to device like you do on the emulator contrary to what the documentation suggests.

like image 145
vkinra Avatar answered Nov 15 '22 18:11

vkinra


Possible if you activate mock locations on your device. Than add ACCESS_MOCK_LOCATION permission to your manifest.

You can write now your own MockLocationManager which generates mocj locations.

Easiest way is to you use an app which generates mock lactions for you. GPS Route Simulator works quite fine. Possible to store kml files on the sdCard or defines own routes

like image 41
prototyp Avatar answered Nov 15 '22 18:11

prototyp