Use a local-only Wi-Fi hotspot

You can use a local-only hotspot to enable applications on devices connected to the Wi-Fi hotspot to communicate with each other. The network created by this method will not have Internet access. Each application can make a single request for the hotspot, but multiple applications can request the hotspot at the same time. When multiple applications have successfully registered concurrently, they share the underlying hotspot. LocalOnlyHotspotCallback.onStarted(LocalOnlyHotspotReservation) is called when the hotspot is ready for use.

If your app targets Android 13 (API level 33) or higher, you must request the NEARBY_WIFI_DEVICES to use a local-only hotspot, as shown in the following code snippet. Apps that target an earlier version of Android must request ACCESS_FINE_LOCATION instead.

 ...>
    <
     android:name="android.permission.NEARBY_WIFI_DEVICES"
                     
                     android:usesPermissionFlags="neverForLocation" />
     android:name="android.permission.ACCESS_FINE_LOCATION"
                     
                     android:maxSdkVersion="32" />
     ...>
        ...
    

For more details on using local-only hotspots, see startLocalOnlyHotspot().