I know how to set locatlon for emulators using device configuration interface from Motodoev Studio for example. But, how I can set locatlon for a device?

up vote 6 down vote accepted

To add to Jared's answer (can't comment - not enough reputation yet :/). This works with the emulator only so I wrote an app you can run on a real device and it provides exactly the same interface (telnet to :5554 and run "geo fix ..." or "geo nmea"): MockGeoFix

  • mockgeofix is not connecting throught telnet – user54098 Jun 24 '16 at 18:48
  • mockgeofix runs the telnet sever and you connect to mockgeofix using telnet – luv Jun 25 '16 at 11:40

this is possible using ADB shell:

$ telnet localhost 5554
Android Console: type 'help' for a list of commands
OK
geo fix -82.411629 28.054553
OK

Please read: https://stackoverflow.com/a/2587369/950427

  • isn't this for a device? AFAIK, there is no way to set the location other than mock the location on your device, and add a test location provider. – Avinash R Jul 14 '13 at 17:39
  • Yes, I believe this is what he was looking for. What is your question? – Jared Burrows Jul 14 '13 at 18:57
  • 2
    Down vote because OP is explicitly asking about on a Device. This only works for the Emulator. – cde Jul 14 '16 at 17:05
  • @cde I answered this question 3.5+ years ago. It helped OP at the time. – Jared Burrows Jul 15 '16 at 14:13

Alternatively what might also be an option here is to use Appium's io.appium.setting's app.

Once that app's installed on the device you can give it permissions and mock location through adb like this:

  adb shell pm grant io.appium.settings android.permission.READ_PHONE_STATE
  adb shell pm grant io.appium.settings android.permission.WRITE_SETTINGS
  adb shell pm grant io.appium.settings android.permission.ACCESS_FINE_LOCATION
  adb shell pm grant io.appium.settings android.permission.ACCESS_COARSE_LOCATION
  adb shell pm grant io.appium.settings android.permission.ACCESS_MOCK_LOCATION
  adb shell pm grant io.appium.settings android.permission.SET_ANIMATION_SCALE
  adb shell pm grant io.appium.settings android.permission.CHANGE_CONFIGURATION

  adb shell am start -W -n io.appium.settings/.Settings -a android.intent.action.MAIN -c android.intent.category.LAUNCHER -f 0x10200000
  adb shell appops set io.appium.settings android:mock_location allow

  adb shell am startservice -e longitude 28 -e latitude 77 io.appium.settings/.LocationService;

For more info on the app and some other intents check out their readme

New contributor
jmp is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.