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.
- B opens a listening port
- A opens the file as an input stream
- A connects to B's listening port
- A sends the file through the socket
- A closes the socket
- B writes its buffer in a new file
Check this reference and ask if you have any problems.