Get started
Stay organized with collections
Save and categorize content based on your preferences.
Before you begin
Before you start to code using the Nearby Connections API:
Request permissions
Before using Nearby Connections, your app must request the appropriate
permissions. Add the following permissions to your AndroidManifest.xml
:
<!-- Required for Nearby Connections -->
<uses-permission android:maxSdkVersion="31" android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:maxSdkVersion="31" android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:maxSdkVersion="30" android:name="android.permission.BLUETOOTH" />
<uses-permission android:maxSdkVersion="30" android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:maxSdkVersion="28" android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:minSdkVersion="29" android:maxSdkVersion="31" android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:minSdkVersion="31" android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:minSdkVersion="31" android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:minSdkVersion="31" android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:minSdkVersion="32" android:name="android.permission.NEARBY_WIFI_DEVICES" />
<!-- Optional: only required for FILE payloads -->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
Since
ACCESS_FINE_LOCATION,
BLUETOOTH_ADVERTISE,
BLUETOOTH_CONNECT,
BLUETOOTH_SCAN
and
READ_EXTERNAL_STORAGE
are considered to be dangerous system
permissions,
in addition to adding them to your manifest, you must request these permissions
at runtime, as described in Requesting
Permissions.
If the user does not grant all required permissions, the Nearby Connections API
will refuse to allow your app to start advertising or discovering.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-08-12 UTC.
[null,null,["Last updated 2025-08-12 UTC."],[[["\u003cp\u003eBefore using the Nearby Connections API, install the Google Play Services SDK and review the provided code samples.\u003c/p\u003e\n"],["\u003cp\u003eApps using Nearby Connections must request specific permissions in the \u003ccode\u003eAndroidManifest.xml\u003c/code\u003e to function correctly.\u003c/p\u003e\n"],["\u003cp\u003eSeveral permissions, like location and Bluetooth access, require runtime requests due to their sensitive nature.\u003c/p\u003e\n"],["\u003cp\u003eThe Nearby Connections API will not function if the user denies necessary permissions for advertising or discovery.\u003c/p\u003e\n"]]],["To use the Nearby Connections API, install the Google Play Services SDK and review the code samples. In your `AndroidManifest.xml`, add permissions for `ACCESS_WIFI_STATE`, `CHANGE_WIFI_STATE`, `BLUETOOTH`, `BLUETOOTH_ADMIN`, `ACCESS_COARSE_LOCATION`, `ACCESS_FINE_LOCATION`, `BLUETOOTH_ADVERTISE`, `BLUETOOTH_CONNECT`, `BLUETOOTH_SCAN`, and `NEARBY_WIFI_DEVICES`. For `ACCESS_FINE_LOCATION`, `BLUETOOTH_ADVERTISE`, `BLUETOOTH_CONNECT`, `BLUETOOTH_SCAN` and `READ_EXTERNAL_STORAGE` also request these permissions at runtime, as they are classified as dangerous. The app can not use the API if the user does not provide the permissions.\n"],null,["# Get started\n\nBefore you begin\n----------------\n\nBefore you start to code using the Nearby Connections API:\n\n- Install the [Google Play Services\n SDK](//developer.android.com/google/play-services/setup.html).\n- Download and review the [Nearby Connections API code\n samples](https://github.com/android/connectivity-samples/tree/main/NearbyConnectionsWalkieTalkie).\n\nRequest permissions\n-------------------\n\nBefore using Nearby Connections, your app must request the appropriate\npermissions. Add the following permissions to your `AndroidManifest.xml`: \n\n```gdscript\n\u003c!-- Required for Nearby Connections --\u003e\n\u003cuses-permission android:maxSdkVersion=\"31\" android:name=\"android.permission.ACCESS_WIFI_STATE\" /\u003e\n\u003cuses-permission android:maxSdkVersion=\"31\" android:name=\"android.permission.CHANGE_WIFI_STATE\" /\u003e\n\u003cuses-permission android:maxSdkVersion=\"30\" android:name=\"android.permission.BLUETOOTH\" /\u003e\n\u003cuses-permission android:maxSdkVersion=\"30\" android:name=\"android.permission.BLUETOOTH_ADMIN\" /\u003e\n\u003cuses-permission android:maxSdkVersion=\"28\" android:name=\"android.permission.ACCESS_COARSE_LOCATION\" /\u003e\n\u003cuses-permission android:minSdkVersion=\"29\" android:maxSdkVersion=\"31\" android:name=\"android.permission.ACCESS_FINE_LOCATION\" /\u003e\n\u003cuses-permission android:minSdkVersion=\"31\" android:name=\"android.permission.BLUETOOTH_ADVERTISE\" /\u003e\n\u003cuses-permission android:minSdkVersion=\"31\" android:name=\"android.permission.BLUETOOTH_CONNECT\" /\u003e\n\u003cuses-permission android:minSdkVersion=\"31\" android:name=\"android.permission.BLUETOOTH_SCAN\" /\u003e\n\u003cuses-permission android:minSdkVersion=\"32\" android:name=\"android.permission.NEARBY_WIFI_DEVICES\" /\u003e\n\u003c!-- Optional: only required for FILE payloads --\u003e\n\u003cuses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/\u003e\n```\n\nSince\n[ACCESS_FINE_LOCATION](https://developer.android.com/reference/android/Manifest.permission#ACCESS_FINE_LOCATION),\n[BLUETOOTH_ADVERTISE](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_ADVERTISE),\n[BLUETOOTH_CONNECT](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_CONNECT),\n[BLUETOOTH_SCAN](https://developer.android.com/reference/android/Manifest.permission#BLUETOOTH_SCAN)\nand\n[READ_EXTERNAL_STORAGE](https://developer.android.com/reference/android/Manifest.permission#READ_EXTERNAL_STORAGE)\nare considered to be [dangerous system\npermissions](//developer.android.com/guide/topics/permissions/requesting.html#normal-dangerous),\nin addition to adding them to your manifest, you must request these permissions\nat runtime, as described in [Requesting\nPermissions](//developer.android.com/training/permissions/requesting.html).\n\nIf the user does not grant all required permissions, the Nearby Connections API\nwill refuse to allow your app to start advertising or discovering."]]