File transfer over Wi-Fi in Android

别来无恙 提交于 2019-12-11 03:32:31

问题


I want to make an Android app which can transfer a file from one phone to another via Wi-Fi. In Android 4.0 it can be done through Wi-Fi direct but how it would be possible for lower versions that do not support Wi-Fi direct?


回答1:


You can do this by opening a network connection. This will work over Wifi or any connection the device has. Let's say device A wants to send to device B a file.

  1. B opens a listening port
  2. A opens the file as an input stream
  3. A connects to B's listening port
  4. A sends the file through the socket
  5. A closes the socket
  6. B writes its buffer in a new file

Check this reference and ask if you have any problems.



来源:https://stackoverflow.com/questions/13002222/file-transfer-over-wi-fi-in-android

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