如何将 GPS 坐标从一部 Android 手机发送到另一部手机?
我正在编写一个 Android 应用程序,希望能让我和一些朋友看到彼此在哪里。它要求每部手机互相发送 GPS 坐标。有没有办法在 SDK/Java 中做到这一点?将包含的每个设备都将被硬编码并且无法更改。感谢我能得到的任何帮助!
I am writing a android application that will hopefully let me and a few friends see where each other are. It requires each phone to send the gps coordinates to each other. Is there anyway to do that in the SDK / Java? Each device that will be included will be hard coded and can't be changed. Thanks for any help I can get!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
传递 GPS 坐标没有特殊的技巧。您必须使用标准方法,例如设置中央服务器来接收和广播一些坐标,或者您可以使用短信自动传递详细信息。
There is no special trick to passing around GPS coordinates. You'll have to used standard ways like setting up a central server to receive and broadcast some coordinates or you could use SMS's to pass the details around automatically.
您可能需要考虑让每个设备将其位置存储在服务器上的某个位置,而不是尝试直接连接到每个设备。这有几个优点:
服务器很容易找到。所有设备都知道它的地址。
每台设备仅需要一个网络连接即可获取所有其他设备的最新位置。对于三台设备来说,相互连接可能不是什么大问题,但对于一到两打设备来说,这就是一个问题。
服务器更有可能可达。
使用服务器不一定很复杂。您真正需要做的就是让每个设备将文件发布到公共目录。
Rather than trying to connect to each of the devices directly, you might want to consider having each device store its location on a server somewhere. That has several advantages:
The server is easy to find. It's address is known by all the devices.
Each device only needs one network connection to get the latest locations of all the other devices. It might not be a big deal for three devices to all connect to each other, but it's a problem for as few as one or two dozen devices.
The server is more likely to be reachable.
Using a server doesn't have to be complicated. All you really need to do is let each device post a file to a common directory.