我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
我想在Android模拟器中获得经度和纬度进行测试。
有谁能指导我如何实现这个目标吗?
如何将模拟器的位置设置为测试位置?
当前回答
对于BlueStack用户:打开模拟器,按Ctrl+Shift +K,然后找到你的位置,并按下设置位置!
其他回答
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.
如果您正在使用Eclipse,请转到窗口->打开透视图->DDMS,然后在位置控制中键入1并单击发送。
对于Android Studio用户:
运行模拟器,
然后进入“工具->Android ->Android设备监视器”
打开模拟器控件选项卡,并使用位置控件组。
在eclipse中:
您可能需要向下拖动DDMS窗口。 “Location Controls”位于“Telephony Actions”下,可能会被一个正常大小的控制台视图隐藏(控制台,LogCat等栏可能会覆盖它!)
~
我已经做了一个类似于前面的答案之一的小脚本,但使用expect而不是python -因为它更简单一点(expect是为此而发明的)。
#!/usr/bin/expect
set port [lindex $argv 0]
set lon [lindex $argv 1]
set lat [lindex $argv 2]
set timeout 1
spawn telnet localhost $port
expect_after eof { exit 0 }
## interact
expect OK
set fp [open "~/.emulator_console_auth_token" r]
if {[gets $fp line] != -1} {
send "auth $line\r"
}
send "geo fix $lon $lat\r"
expect OK
send "exit\r"
示例用法:sendloc 5554 2.35607 48.8263