
Indicates the state of Wi-Fi Direct connectivity has changed. In your application, instantiateĪn IntentFilter and set it to listen for the following: WIFI_P2P_STATE_CHANGED_ACTION Indicates whether Wi-Fi Direct is enabled WIFI_P2P_PEERS_CHANGED_ACTION Indicates that the available peer list has changed.

To use Wi-Fi Direct, you need to listen for broadcast intents that tell yourĪpplication when certain events have occurred. Set up a broadcast receiver and peer-to-peer manager So you need the following permissions to use Wi-Fi Direct:Īndroid:usesPermissionFlags="neverForLocation" />īesides the preceding permissions, the following APIs also require Location Mode to be enabled: If your app targets Android 13 (API level 33) or higher, also add theĭirect doesn't require an internet connection, but it does use standard Java This lesson shows you how to find and connect to nearby devices using Wi-Fi P2P.

If your app is designed to be a part of a secure, near-range network, Wi-Fiĭirect is a more suitable option than traditional Wi-Fi ad-hoc Needing to connect to a network or hotspot. The Wi-Fi Direct (P2P) APIs allow applications to connect to nearby devices without Wi-Fi Direct (also known as peer-to-peer or P2P) allows your application to quickly find and interact with nearbyĭevices, at a range beyond the capabilities of Bluetooth.
