简体   繁体   English

Android设备之间的通信

[英]Communication between Android devices

I'm looking for a way to allow a device to send secure notifications to another device with minimal battery loss. 我正在寻找一种允许设备以最小的电池损耗将安全通知发送到另一台设备的方法。 I am currently doing this using a SSLServerSocket however I feel like keeping a socket constantly open is very poor for battery life. 我目前正在使用SSLServerSocket进行此操作,但是我觉得保持套接字持续打开对电池寿命非常不利。 The other option I considered was to just have a socket listening for a connection but I'm not sure if this is any better. 我考虑的另一个选择是只让套接字监听连接,但是我不确定这是否更好。 I need the notifications to be sent instantly so using a timer and connecting every x number of minutes is not optimal. 我需要立即发送通知,因此使用计时器并每隔x分钟连接一次不是最佳选择。 Are there any good ways to achieve this over a wifi connection with minimal battery loss? 有没有什么好的方法可以通过wifi连接实现此目的,并且电池损耗最小?

perhaps you can use C2DM (Cloud2DeviceMessaging). 也许您可以使用C2DM (Cloud2DeviceMessaging)。 This may not be the perfect solution for you but instead of all the devices asking all the time for updates the server tells them they do. 对于您来说,这可能不是一个完美的解决方案,而是代替所有设备一直询问更新的服务器告诉他们他们这样做。

Device A send a message to Device B -> Device A sends the message to the server -> Server notifies Device B that it has a message -> Device B asks the server for that message 设备A向设备B发送消息->设备A向服务器发送消息->服务器通知设备B它有消息->设备B向服务器询问该消息

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

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