What Is Wi‑Fi Aware?
Wi‑Fi Aware, also known as Neighbor Awareness Networking (NAN), lets compatible devices discover services and communicate directly over Wi‑Fi, without an access point or other connectivity between them. It does not provide Internet access by itself: it creates a local communication path between nearby devices.
On Android, the feature has been available since Android 8.0 (API 26), but installing that version is not enough. The device must support Wi‑Fi Aware: the manufacturer needs to provide support in the framework, HAL, and firmware. Actual availability therefore depends on the device, not just the Android version.
Direct connections can be useful for sharing information between devices that are not connected to a traditional network. Wi‑Fi Alliance describes data- and service-sharing scenarios between nearby devices, and Android notes that Wi‑Fi Aware connections can support higher transfer rates than Bluetooth over longer distances. Actual performance depends on the devices and conditions of use; that comparison does not guarantee a specific speed or range.
How Discovery and Connection Work
The process starts when one device publishes a service and another subscribes to it. For example, an app can advertise a file-sharing service while another searches for it. When the subscriber enters the publisher’s Wi‑Fi range, the system notifies the app that it has found a matching service.
Finding a service does not mean that a data connection is already established. After discovery, the subscriber can send a short message or start setting up a bidirectional network connection. For a client-server connection, Android’s guide describes additional signaling steps and network requests on both devices.
A device can publish and subscribe at the same time. Wi‑Fi Aware also organizes nearby devices into clusters. The system service manages this grouping; apps use APIs to request discovery, message-sending, and connection operations, but they do not control how the groups are formed.
Android Requirements and Availability
An app can check whether Android declares Wi‑Fi Aware on the device by using PackageManager.hasSystemFeature(PackageManager.FEATURE_WIFI_AWARE). It can then check whether the feature is currently available with WifiAwareManager.isAvailable(). Support and current availability are separate checks: a device may support the feature even when it cannot temporarily be used.
Availability may be affected if the user turns off Wi‑Fi or location. Depending on hardware and firmware capabilities, some devices also do not support Wi‑Fi Aware while Wi‑Fi Direct, SoftAP, or tethering is in use. An app should therefore not assume that the feature will remain active throughout a session.
Android recommends listening for ACTION_WIFI_AWARE_STATE_CHANGED, which reports availability changes. When notified, the app should discard existing sessions and check the state again before deciding what to do. Handling interruptions is part of the implementation: if Wi‑Fi Aware becomes unavailable, the software must adapt its behavior and, where appropriate, start new sessions after the service returns.
Permissions and the Session Lifecycle
Android’s guide lists Wi‑Fi and network permissions such as ACCESS_WIFI_STATE, CHANGE_WIFI_STATE, CHANGE_NETWORK_STATE, and INTERNET. Apps targeting Android 13 (API 33) or later must also declare NEARBY_WIFI_DEVICES. If an app obtains location information through Wi‑Fi APIs, it must not include the neverForLocation attribute.
The documentation includes ACCESS_FINE_LOCATION with maxSdkVersion="32" for apps that need precise location information. If a feature depends on that information, Android says not to include this version limit. Permissions should match what the app does and the conditions documented by Android; there is no identical recipe for every feature.
To start using Wi‑Fi Aware, an app calls attach() and receives a session that contains the publish or subscribe sessions. Android recommends calling attach() only once in most cases: additional calls create separate sessions, each with its own namespace. Discovery sessions belong to the main session, so they should be explicitly closed when no longer needed.
Features Documented in Android 12 and 13
Android 12 (API 31) added onServiceLost(), which lets an app know when a discovered service is no longer available because it has stopped or moved out of range. It also simplified data-path setup: the responding device can be configured to accept any peer without knowing the initiator’s MAC address in advance. getAvailableAwareResources() can be used to check available resources, such as data paths and publish or subscribe sessions.
On devices running Android 13 (API 33) or later that support instant communication mode, apps can enable it in publish or subscribe configuration. Android says this mode speeds up message exchange, service discovery, and data-path setup. An app can check whether the device supports it by calling isInstantCommunicationModeSupported(); this capability is not guaranteed on every device.
Ranging: Measuring the Distance Between Devices
Wi‑Fi Aware can use ranging to measure the distance to another device and limit discovery to a defined area. On Android, this feature uses IEEE 802.11mc, also known as Round Trip Time (RTT). Using it requires a device to support both Wi‑Fi Aware and Wi‑Fi RTT.
Android gives an example discovery interval of between 3 and 10 meters. To apply the limit, the publisher must enable ranging, and the subscriber must set the corresponding minimum or maximum distance. If the publisher does not enable measurement, the subscriber’s distance restrictions are ignored and normal discovery takes place.
When a service is discovered within the configured range, the app can receive onServiceDiscoveredWithinRange, which provides the measured distance. Measurement depends on support and configuration at both ends; it should not be interpreted as a guarantee of precise location or as a feature available on every device.
Privacy and Practical Limitations
Android requires the MAC addresses of Wi‑Fi Aware discovery and data interfaces to be randomized and different from the device’s real MAC address. They must be randomized again when Wi‑Fi Aware is activated or reactivated; with the framework’s default configuration, the periodic interval is 30 minutes. Wi‑Fi Alliance also describes privacy protections, including pairing identities that only paired devices can resolve and periodic changes to transmitted identities.
Wi‑Fi Aware does not replace an Internet connection. Its purpose is to enable local discovery and communication; an app that requires online services must handle that connection separately. Also, because availability can change, an app needs to manage interruptions rather than treating a session as permanent.
On Android 14 and later, privileged apps can suspend and resume active discovery sessions if the device and its firmware provide the necessary support. Android notes that this capability can speed up resumption and reduce power consumption. Before relying on Wi‑Fi Aware for a feature, check compatibility and availability on every participating device, and design the software to respond to state changes.