我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
当前回答
如果你使用Android Studio (1.3):
点击菜单“工具” “Android” “Android设备监视器” 单击当前模拟器 选项卡“模拟器控制” 进入“位置控制”,输入纬度和高度
其他回答
如果上述解决方案不奏效。试试这个:
在你的android manifest .xml中,在应用程序标记之外添加以下两个链接,当然是在你的manifest标记中
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" ></uses-permission>
<uses-permission android:name="android.permission.INTERNET" ></uses-permission>
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.
在Mac、Linux或Cygwin系统下:
echo 'geo fix -99.133333 19.43333 2202' | nc localhost 5554
这样你就能到墨西哥城了。相应地改变你的经度/纬度/高度。如果你对nmea不感兴趣,这应该足够了。
把阿尔贝托·高纳的回答写在一行里
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能够发挥作用,情况会更好。
如果你正在使用eclipse,然后使用模拟器控制器,你可以手动设置纬度和经度,并在模拟器中运行基于地图的应用程序