我想在Android模拟器中获得经度和纬度进行测试。

有谁能指导我如何实现这个目标吗?

如何将模拟器的位置设置为测试位置?


当前回答

如果你使用Android Studio (1.3):

点击菜单“工具” “Android” “Android设备监视器” 单击当前模拟器 选项卡“模拟器控制” 进入“位置控制”,输入纬度和高度

其他回答

Android Studio有一个名为“Mock Location plugin”的插件。 你可以用这个插件模拟多个点。 你可以在这个链接中找到详细的使用手册:Android Studio。用模拟位置插件模拟多个GPS点

1. Android Studio用户。

运行模拟器后进入Tools->Android->Android设备监视器

从位置控件组中单击“模拟器控件”选项卡更改。

2. Eclipse用户。

首先在Eclipse菜单中选择“窗口”,然后选择“打开透视图”,然后选择“DDMS”。 即窗口->打开透视->DDMS。

你会看到左边设备面板和右边你会看到不同的选项卡。 选择“模拟器控制”选项卡。

在底部你会看到位置控制面板。 选择“手动”选项卡。

在文本框中输入经度和纬度,然后单击发送按钮。 它会将位置发送给模拟器和应用程序。

3.使用telnet。

在run命令中键入this。

telnet localhost 5554

如果您不使用windows,您可以使用任何telnet客户端。

连接到telnet后,使用以下命令将您的位置发送到模拟器。

geo fix long lat    
geo fix -121.45356 46.51119 4392

4. 使用基于浏览器的谷歌地图工具

有一个程序使用GWT和谷歌Maps API来启动一个基于浏览器的地图工具来设置模拟器中的GPS位置:

android-gps-emulator

The already mentioned multiple times answer to use the shell command "geo fix..." is the correct answer. But in case you use LocationClient.getLastLocation() to retrieve your data it is worth to mention that it will not work at first. The LocationClient class uses the Google Play Service to retrieve the coordinates. For me this started working after running the emulators maps app once. During the first start you are asked to allow google apps access to your location, which I guess does the trick.

把阿尔贝托·高纳的回答写在一行里

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

5554是adb设备中显示的模拟器端口号。

如果亚行的emu能够发挥作用,情况会更好。

对于新的模拟器:

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

基本上,点击模拟器控件中的三个点按钮(模拟器的右侧),它将打开一个菜单,允许你控制模拟器,包括位置