How to transfer files between Android devices using Wi-Fi Direct?

I need to transfer files between Android devices using Wi-Fi Direct. Please give some sample code for this. I searched a lot, but I did not find two-way code.

+7
android wifi wifi-direct
source share
4 answers

https://github.com/mayfourth/WiFi-Direct-File-Transfer

Check it out and try the response code

+7
source share

I made an example application using the WiFiDirect demo provided by Android. But I made some changes when the user can transfer in both directions, from server to client, as well as from client to server.

Here is the APK file

You can download the code here.

+8
source share

I created a sample from

http://developer.android.com/guide/topics/connectivity/wifip2p.html

The following is a description of the process for performing this function.

  • Check if wifi direct is available or not using WifiP2pManager.WIFI_P2P_STATE_ENABLED.
  • To discover peers available for connection, call the DiscoverPeers () function to find available peers in range.
  • If the discovery process completes successfully and detects peers, the system sends WIFI_P2P_PEERS_CHANGED_ACTION an intention that you can listen on the broadcast receiver to obtain a list of peers.
  • When you find out the device you want to connect to after receiving a list of possible peers, call the connect () method to connect to the device.
  • Sockets are used for data transfer. Thus, the combination of the ServerSocket and Socket classes from the network packet actually sends and receives the file.

Please find the file transfer demo at http://trivedihardik.wordpress.com/2012/08/31/android-wifi-direct-example/

+5
source share

Wi-Fi Peer-to-Peer: http://developer.android.com/guide/topics/connectivity/wifip2p.html

Creating P2P connections: http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html

The Direct Direct WiFi app can be found in the SDK:

AndroidSDK\samples\android-19\legacy\WiFiDirectDemo 
+2
source share

All Articles