I am working on an android app where i need to make fake locations at different timings. Is this possible to do this by pushing XML to a android device?
2 Answers
If you're using Eclipse with the Android ADT tools installed, you can switch to the DDMS perspective and under the emulator control options, there are geolocation settings. You can send a single location or use a GPX or KML file to "play back" a series of locations (to simulate driving a route, for example)
You can create KML routes in apps like Google Earth, or code it by hand in XML. Sounds like exactly what you're looking for.
http://www.linuxtopia.org/online_books/android/devguide/guide/developing/tools/ddms.html
There's also an emulator called Genymotion that runs on VirtualBox that has APIS for things like location simulation. I've been using it for a few weeks now and I'm very impressed:

- 3,657
- 5
- 32
- 60
-
Thanks @AWT not sure how can i code it in XML at different location with different timings! – LearningCode May 28 '14 at 15:07
-
1This tutorial on KML is a good start: http://www.htmlgoodies.com/beyond/mobile/providing-gps-coordinates-via-the-eclipse-android-simulator.html. If this answer helped you, please upvote and accept. Thanks! – AWT May 28 '14 at 15:14
-
Also updated the original answer, you might want to look into the Genymotion emulator as well. – AWT May 28 '14 at 15:22
-
i don't think genymotion can simulate driving a route – LearningCode May 28 '14 at 15:24
-
It has an API you can call from outside of the emulator that allows you to set coordinates within the emulator. If you had a shell script with delays, or a simple java program, you could easily send a sequence of coordinates with a delay between each. – AWT May 28 '14 at 15:49
You can use a mock location provider. In your case you could probably have a class in control of the mock provider that feeds data based on some xml file input.
See: Android mock location on device?
It would be easy to implement an interface and switch between live and mock providers. This would allow runtime mocking which I assume is what you are asking for.