如何发送“地理修复”对Android真实设备的命令?
首先,感谢您关注我的问题
我打算设计一个Android GPS定位应用程序,
这里是我的困难和情况
(1)我的电脑硬件已经过时很长一段时间,运行一个android模拟器进行调试是真的很费时间,因此我一周前买了一台真实的设备(android手机),目的是在调试期间更换模拟器
(2)我知道如何通过“DDMS/模拟器控制/位置控制”将位置数据发送到模拟器,但它对于真实设备是禁用的
(3)我正在室内编程,因此使用物理 GPS 定位功能是不可接受的(即使我打开“a-gps”)
(4)我在这里找到了另一个主题:设备上的 Android 模拟位置? 但是,我无法打开详细链接,例如“Andrews link”、“ http://dehuysser.appspot.com/blog/android-developer-shell-released”
我猜这些网站被我国禁止......
这是我的问题:
(A)我有找到了一些制作模拟位置数据的代码,但是这些代码无法激活“onLocationChanged”功能
但是,我想知道是否有一种方法可以通过USB端口将定位数据从PC发送到真实设备(我处于USB调试模式),就像将位置从 DDMS 发送到模拟器一样?
(B)我得到的信息是,可以通过“telnet localhost”向模拟器以及真实设备发送“geo fix”命令,但是如何查看我的真实设备占用的端口号?
我知道5554端口用于模拟器,但是真实设备呢?
我尝试在终端中命令“netstat”,但遗憾的是我不知道哪个端口适用于我的 Android 手机......
(C)如果我的 (A)(B) 问题是不实用,那么“设置/应用程序/开发/允许模拟位置”是用来做什么的?
请帮助我,谢谢您的回答!
First,thank you for your attention to my question
I'm planning to design an Android GPS locating application
here are my difficulties and situations
(1)my computer hardware has been out of date for a long time and running an android emulator for debugging is really time-costing,thus i bought a real device(android cellphone) one week ago,in the aim of replacing emulator during debugging
(2)i know how to send location datas to an emulator via "DDMS/Emulator Control/Location Controls",but it is disabled for a real device
(3)i am programming indoor,thus using physical gps locating function is not acceptable(even if i turn on "a-gps")
(4)i have found another topic here: Android mock location on device?
however,i can't open the detail links,like "Andrews link"," http://dehuysser.appspot.com/blog/android-developer-shell-released"
I guess these web sites are forbidden by my country......
Here are my questions:
(A)i have found some codes of making mock loation datas ,but these codes can not activate "onLocationChanged" function
However, i wonder if there is a way to send locating datas from PC to real device via USB port(i'm in USB debugging mode), just like sending locations from DDMS to emulator?
(B)i've got the information that, it is possible to send "geo fix" command to emulator as well as to a real device, by "telnet localhost ", but how to check out the port number occupied by my real device?
i know that 5554 port is used for a emulator,but what about the real device?
i've tried to command "netstat" in terminal, but it's a shame to say that i don't know which port is for my android phone......
(C)If my (A)(B) question is not practical,then what's "settings/applications/development/allow mock location" used for?
Please help me, and thank you for your answer!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我专门为此编写了一个应用程序(默认情况下,手机上不提供此功能) - 它是开源并提供与模拟器完全相同的界面(telnet 到 :5554 并运行“geo fix ...”或“geo nmea”):在应用商店 MockGeoFix
I have wrote an app exactly for this (this functionality is not available on phones by default) - it's open source and provides exactly the same interface as the emulator (telnet to :5554 and run "geo fix ..." or "geo nmea"): in app store MockGeoFix
使用模拟数据的最简单方法是使用模拟测试位置提供程序 API。它位于文档页面的底部。我已经尝试过,并且在 onLocationChanged 回调中收到了位置。 此处 是一些您可以尝试的代码。
adb使用的端口通常是5037。
The easiest way of using mock data is using the mock test location provider API. It's at the bottom of the documentation page. I've tried it out and location is received in the onLocationChanged callback. Here is some code that you can try out.
The port used by adb is usually 5037.