智能手机可以通过 3G/4G 进行点对点通信吗?
我正在尝试编写一个应用程序,将数据从一个 Android 设备传输到另一个 Android 设备 - 但这些设备很可能位于城市、州或国家的不同部分。 (直接的方法是拥有一台中央服务器(或任何类型的服务器),但我试图避免使用中央服务器)。
我试图传递的数据是文本、图片或两者的组合。
到目前为止,我找到的解决方案是使用特殊格式的文本或图片消息进行通信;但这似乎远非最佳。还有更好的解决方案吗?
I'm trying to write an app that transfers data from one android device to another - but the devices are most likely located in different parts of the city, state, or country. (The straight forward way would be to have a central server (or any type of server), but i'm trying to avoid using one).
The data I'm trying to pass is text, pictures, or a combination of both.
The solution I've found so far is to communicate with specially formatted text or picture messages; but that seems far from optimal. Any better solutions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
真正的 P2P 在 3G 上是不可能的。
在您的问题中,您提到您当前使用消息。我假设你指的是短信。
您可以做的是使用具有自定义 MIME 类型的邮件和附件,例如
application/foobar-data
。在您的应用程序中,人们可以启动包含此附件的 SEND 意图。然后,用户必须选择他的电子邮件程序(或者这可能是自动的),并将其发送给他/她喜欢的任何人。您还可以指定收件人:地址以及您的意图的主题。这会相当简单。
然后,远程用户将收到该邮件并点击附件。您的应用程序将使用清单中的意图过滤器注册为处理
application/foobar-data
mimetype,然后自动启动并接收数据。之前生成的邮件正文还可以预先填充有关您的应用程序以及如何安装它的信息,例如“您需要 FooBar 来查看附件。您可以从...安装它”。因此,最终,您的应用程序可以发送和接收自定义数据,而无需依赖专用服务器。
True P2P isn't possible over 3G.
In your question, you mention that you currently use messages. I assume that you mean SMS.
What you could do instead is using mails and attachments with a custom mime type, say
application/foobar-data
.Within your app one could launch a SEND intent containing this attachment. The user would then have to choose his email program (or this could maybe be automatic), and send it to whoever he/she likes. You may also specify the To: address, and the subject in your intent. This would be rather straightforward.
The remote user would then receive this mail and tap on the attachment. Your app would be registered to handle the
application/foobar-data
mimetype, using an intent filter in the manifest, and would then automatically launch and receive the data. The body of the mail generated earlier could also be pre-filled with informations about your app and how to install it, such as "You need FooBar to view the attachment. You can install it from...".And so, in the end, your app could both send custom data and receive it, without relying on a dedicated server.
使用 Amazon Simple Queue Service:
Use Amazon Simple Queue Service:
看看 ShazzleMail。您可以下载他们的应用程序并通过智能手机进行点对点通信。寻址是通过中间人完成的,但所有内容都是 p2p 的。
Look at ShazzleMail. You can download their app and communicate p2p over a smartphone. Addressing is done through a middleman, but all content goes p2p.