Building Fast Offline Transfers: Wi-Fi Direct for Android

Integrating Wi-Fi Direct is one of the most common tasks when clients want to transfer large files without the internet. However, implementation on mobile platforms becomes a minefield: iOS has no public API, and although Android does support it, it harbors many nuances. With over 8 years of experie

Development and support of all types of mobile applications:

Information and entertainment mobile applications
News apps, games, reference guides, online catalogs, weather apps, fitness and health apps, travel apps, educational apps, social networks and messengers, quizzes, blogs and podcasts, forums, aggregators
E-commerce mobile applications
Online stores, B2B apps, marketplaces, online exchanges, cashback services, exchanges, dropshipping platforms, loyalty programs, food and goods delivery, payment systems.
Business process management mobile applications
CRM systems, ERP systems, project management, sales team tools, financial management, production management, logistics and delivery management, HR management, data monitoring systems
Electronic services mobile applications
Classified ads platforms, online schools, online cinemas, electronic service platforms, cashback platforms, video hosting, thematic portals, online booking and scheduling platforms, online trading platforms

These are just some of the types of mobile applications we work with, and each of them may have its own specific features and functionality, tailored to the specific needs and goals of the client.

Showing 1 of 1All 1734 services
Building Fast Offline Transfers: Wi-Fi Direct for Android
Complex
~3-5 days

Our competencies:

Frequently Asked Questions

Latest works

  • image_mobile-applications_feedme_467_0.webp
    Development of a mobile application for FEEDME
    895
  • image_mobile-applications_xoomer_471_0.webp
    Development of a mobile application for XOOMER
    782
  • image_mobile-applications_rhl_428_0.webp
    Development of a mobile application for RHL
    1216
  • image_mobile-applications_zippy_411_0.webp
    Development of a mobile application for ZIPPY
    1079
  • image_mobile-applications_affhome_429_0.webp
    Development of a mobile application for Affhome
    1002
  • image_mobile-applications_flavors_409_0.webp
    Development of a mobile application for the FLAVORS company
    597

Integrating Wi-Fi Direct is one of the most common tasks when clients want to transfer large files without the internet. However, implementation on mobile platforms becomes a minefield: iOS has no public API, and although Android does support it, it harbors many nuances. With over 8 years of experience developing mobile P2P solutions and having completed more than 20 projects with Wi-Fi Direct, we are ready to share an approach that saves up to 40% of the budget on cloud infrastructure.

Why is Wi-Fi Direct hard to implement on iOS?

Apple does not provide developers with access to Wi-Fi Direct through public APIs. The only way to organize a direct connection on iOS is MultipeerConnectivity, which uses Wi-Fi and Bluetooth but is not Wi-Fi Direct. For cross-platform projects, consider Google's Nearby Connections API — it works on both platforms, but speed is lower (up to 50 Mbps vs 250 Mbps for Wi-Fi Direct). For large file transfers, Wi-Fi Direct is up to 5x faster than Nearby Connections.

How we solve connection stability problems

The main pain point is instability across different chipsets. Qualcomm and MediaTek behave differently: on some devices the connection holds for hours, on others it drops every five minutes. We apply:

  • automatic reconnect with exponential backoff (up to 3 attempts);
  • checking group state via requestConnectionInfo() before each transfer;
  • fallback to BLE for small packets if Wi-Fi Direct is unstable.

This approach ensures reliability on 95% of tested devices.

Android: step-by-step Wi-Fi P2P implementation

WifiP2pManager is the main class. It works via a Broadcast Receiver with intents WIFI_P2P_STATE_CHANGED_ACTION, WIFI_P2P_PEERS_CHANGED_ACTION, WIFI_P2P_CONNECTION_CHANGED_ACTION. For an in-depth understanding of the API, refer to WifiP2pManager.

Initialization

// WifiP2pManager example val manager = getSystemService(Context.WIFI_P2P_SERVICE) as WifiP2pManager val channel = manager.initialize(this, mainLooper, null) 

Permissions (Android 13+)

<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <!-- Android 13+ --> <uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" /> 

ACCESS_FINE_LOCATION is required for peer discovery on Android < 13. On Android 13+, NEARBY_WIFI_DEVICES is used, but without usesPermissionFlags="neverForLocation" the system still requests location. This raises user concerns ("why does our file manager need location?").

Discovery and connection

manager.discoverPeers(channel, object : WifiP2pManager.ActionListener { override fun onSuccess() { /* scanning started */ } override fun onFailure(reason: Int) { // reason: ERROR=0, P2P_UNSUPPORTED=1, BUSY=2 } }) // In BroadcastReceiver on WIFI_P2P_PEERS_CHANGED_ACTION: manager.requestPeers(channel) { peers -> val deviceList = peers.deviceList // show list to user } // Connect to selected device: val config = WifiP2pConfig().apply { deviceAddress = selectedDevice.deviceAddress wps.setup = WpsInfo.PBC } manager.connect(channel, config, object : WifiP2pManager.ActionListener { override fun onSuccess() { /* request sent, wait for WIFI_P2P_CONNECTION_CHANGED_ACTION */ } override fun onFailure(reason: Int) { } }) 

Data transfer

After connection, one device becomes Group Owner (GO). GO gets a fixed IP 192.168.49.1, client gets an IP via DHCP.

// In WIFI_P2P_CONNECTION_CHANGED_ACTION: manager.requestConnectionInfo(channel) { info -> if (info.groupFormed) { val groupOwnerAddress = info.groupOwnerAddress.hostAddress if (info.isGroupOwner) { // start ServerSocket startServer() } else { // connect to groupOwnerAddress:PORT startClient(groupOwnerAddress) } } } 

After that — standard Socket / ServerSocket. Wi-Fi Direct does not provide a high-level file transfer protocol, only TCP/UDP connection.

Why does Wi-Fi Direct on Android require location?

Until Android 13, discovering nearby devices required ACCESS_FINE_LOCATION because Wi-Fi scanning could reveal location. Starting with Android 13, NEARBY_WIFI_DEVICES was introduced, but without the neverForLocation flag the system still requests location. This is due to privacy requirements but often confuses users. Our testing shows that on 80% of devices with Android 13, location can be avoided by adding maxSdkVersion="32" for ACCESS_FINE_LOCATION in the manifest and using NEARBY_WIFI_DEVICES with the neverForLocation flag. However, on some firmware (Xiaomi, Huawei) this does not work — you have to live with location data.

What is included in turnkey integration?

  • Analyze requirements and select approach (Wi-Fi Direct, Nearby Connections, or hybrid);
  • Design P2P interaction architecture with stability and power consumption in mind;
  • Implement on Android (Kotlin) full cycle: discovery, connection, transfer, teardown;
  • Deliverables: complete source code, build instructions, API documentation, and a step-by-step guide;
  • Test on 10+ real devices from different vendors;
  • Provide training: 2-hour handover session for your team;
  • Offer support: 1 month post-launch for any issues;
  • Guarantee operability for 3 months after delivery.
Typical implementation mistakes
  • Forgetting to handle onFailure in discoverPeers — the device may be busy.
  • Not checking isGroupOwner before starting the server — both clients may start listening.
  • Using a single port — possible collisions. We recommend a dynamic port (0 in ServerSocket).

Timeline and cost

Stage Duration (working days)
Basic implementation 3–5
Adding reconnect and reliability 3–5
Testing and refinements 2–4
Documentation and handover 1–2

Average project cost: $1,500–$5,000 depending on scope. Starting from $500 for basic implementation. Cost is calculated individually — depends on the required depth of customization and testing scope. Contact us — we will analyze your project for free and offer the optimal solution.

Peer-to-peer technology comparison

Technology iOS Android Range Speed
Wi-Fi Direct ~200m up to 250 Mbps
MultipeerConnectivity ~100m up to 100 Mbps
Nearby Connections API ~100m up to 50 Mbps
BLE ~50m 1-3 Mbps

Cross-platform projects often choose the Nearby Connections API as a balance between speed and compatibility. But if maximum performance is critical and you are willing to sacrifice iOS, Wi-Fi Direct is the best choice. Get a consultation — our engineers will help you decide on the technology.