Communication between Android devices

别说谁变了你拦得住时间么 提交于 2019-12-12 05:37:07

问题


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. 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. Are there any good ways to achieve this over a wifi connection with minimal battery loss?


回答1:


perhaps you can use 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



来源:https://stackoverflow.com/questions/10307625/communication-between-android-devices

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!