简体   繁体   English

通过互联网通信IP的Android手机服务器客户端

[英]Android phones server client over internet communication IP

Im starting to work on Android app in which I will use two phones to communicate with each other. 我开始在Android应用程序上工作,在该应用程序中,我将使用两部手机相互通信。 I planned to have that communication over internet, maybe if one phone publishes certain data on IP address, server, and other opens that page(client). 我计划通过Internet进行通信,也许如果一部电话在IP地址,服务器上发布某些数据,而其他人打开该页面(客户端)。 Problem is that I haven't god fixed IP address on any phone, can I pass that problem in any other way or I need to consider different ways for communication?? 问题是我没有在任何电话上固定IP地址,可以通过其他任何方式解决该问题,还是需要考虑不同的通信方式? Thank you! 谢谢!

Yes, you cannot directly connect two phones via internet, but you can use a middleware for this purpose. 是的,您不能通过互联网直接连接两部电话,但是您可以为此使用中间件。 Main idea is that the first device send the message to this middleware (server) and the second periodically try to pull them. 主要思想是第一个设备将消息发送到此中间件(服务器),第二个设备定期尝试拉取它们。

There are many ready-to-use solutions for this purpose and the choice of solution depends on your case: which data type you want to transmit (text, binary, multemedia), how fast, etc. For instance for text messaging you can try to use XMPP -protocol or may be C2DM framework will be enough. 为此,有许多现成的解决方案,解决方案的选择取决于您的情况:要传输的数据类型(文本,二进制,多种媒体),传输速度等。例如,对于文本消息,您可以尝试使用XMPP -protocol或C2DM框架就足够了。

Any way the most appropriate solution is to use one of the existed protocols or technologies. 任何最合适的解决方案都是使用现有协议或技术之一。

If your phones are close together, you can try an ah hoc WiFi network. 如果您的手机靠近在一起,则可以尝试ah WiFi网络。 It seems like directly addressing one phone from another using the cellular Internet is about never possible. 似乎几乎不可能使用蜂窝互联网直接从另一个电话寻址一个电话。 It could be possible sometimes for some providers if the two phones are in the same cell perhaps, but you can not rely on it. 对于某些提供商来说,有时可能有两部手机位于同一单元中的情况,但是您不能依靠它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM