How to emulate GPS location in the Android Emulato

2018-12-31 02:23发布

I want to get longitude and latitude in Android emulator for testing.

Can any one guide me how to achieve this?

How do I set the location of the emulator to a test position?

30条回答
何处买醉
2楼-- · 2018-12-31 03:17

For the new emulator:

http://developer.android.com/tools/devices/emulator.html#extended

Basically, click on the three dots button in the emulator controls (to the right of the emulator) and it will open up a menu which will allow you to control the emulator including location

查看更多
唯独是你
3楼-- · 2018-12-31 03:17

Just make Alberto Gaona's answer into one line

token=$(cat ~/.emulator_console_auth_token); cat <(echo -e "auth $token \n  geo fix 96.0290791 16.9041016  \n exit") - | nc localhost 5554

5554 is the emulator port number shown in adb devices.

It would have been better if adb emu work.

查看更多
只靠听说
4楼-- · 2018-12-31 03:17

Open Android studio->Tools menu->Android-> Android Device Monitor->Emulator Tab->Location control-> Set your required latitude and longitude and check your project as per your need

查看更多
泛滥B
5楼-- · 2018-12-31 03:18

1. Android Studio users.

After running the emulator goto Tools->Android->Android device monitor

Click the Emulator Control Tab change from the location controls group.

2. Eclipse users.

First In Eclipse In Menu Select "Window" then Select "Open Perspective" then Select "DDMS". i.e Window->Open Prespective->DDMS.

You will see on Left Side Devices Panel and on Right Side you will see different tabs. Select "Emulator Control" Tab.

At bottom you will see Location Controls Panel. Select "Manual" Tab.

Enter Longitude and Latitude in Textboxs then Click Send Button. It will send the position to you emulator and the application.

3. Using telnet.

In the run command type this.

telnet localhost 5554

If you are not using windows you can use any telnet client.

After connecting with telnet use the following command to send your position to emulator.

geo fix long lat    
geo fix -121.45356 46.51119 4392

4. Use the browser based Google maps tool

There is a program that uses GWT and the Google Maps API to launch a browser-based map tool to set the GPS location in the emulator:

android-gps-emulator

查看更多
宁负流年不负卿
6楼-- · 2018-12-31 03:18

In Mac, Linux or Cygwin:

echo 'geo fix -99.133333 19.43333 2202' | nc localhost 5554

That will put you in Mexico City. Change your longitude/latitude/altitude accordingly. That should be enough if you are not interested in nmea.

查看更多
还给你的自由
7楼-- · 2018-12-31 03:18

For a project of my own, I developed an online service which can provide simulated location to the Android emulator.

It uses geo nmea rather than geo fix which allows it to set speed, course, precise time etc. in addition to just lat/lon.

The service requires the nc (netcat) command line utility and nothing else.

http://www.kisstech.ch/nmea/

查看更多
登录 后发表回答