Yakındaki kablosuz cihazlara erişmek için izin isteyin
Koleksiyonlar ile düzeninizi koruyun
İçeriği tercihlerinize göre kaydedin ve kategorilere ayırın.
Android 13'ü (API düzeyi 33) veya sonraki sürümleri hedefleyen ve Wi-Fi bağlantılarını yöneten uygulamalar, NEARBY_WIFI_DEVICESçalışma zamanı izni istemelidir. Bu izin, bir uygulamanın yakındaki kablosuz cihazlara erişimini haklı göstermeyi kolaylaştırır. Android'in önceki sürümlerinde bu uygulamaların bunun yerine ACCESS_FINE_LOCATION iznini bildirmesi gerekiyordu.
İzin, yakındaki cihazlar grubunun bir parçasıdır.
NEARBY_WIFI_DEVICES izni, Yakındaki cihazlar izin grubunun bir parçasıdır. Android 12'de (API düzeyi 31) eklenen bu grup, Bluetooth ve ultra geniş bant ile ilgili izinleri de içerir. Bu izin grubundan herhangi bir izin kombinasyonu istediğinizde sistem, tek bir çalışma zamanı iletişim kutusu gösterir ve kullanıcıdan uygulamanızın yakındaki cihazlara erişimini onaylamasını ister.
Kullanıcı, sistem ayarlarında Yakındaki cihazlar izinlerini grup olarak etkinleştirmeli ve devre dışı bırakmalıdır. Örneğin, kullanıcılar belirli bir uygulama için Wi-Fi erişimini devre dışı bırakıp Bluetooth erişimini etkin tutamaz.
Uygulamanızın fiziksel konum elde etmediğini net bir şekilde belirtin.
Android 13 veya sonraki sürümleri hedeflediğinizde uygulamanızın konum bilgilerini Wi-Fi API'lerinden alıp almadığını göz önünde bulundurun. Almıyorsa bunu kesin bir şekilde belirtmeniz gerekir. Bu beyanı yapmak için aşağıdaki kod snippet'inde gösterildiği gibi uygulamanızın manifesto dosyasında usesPermissionFlags özelliğini neverForLocation olarak ayarlayın. Bu işlem, Bluetooth cihaz bilgilerinin konum için hiçbir zaman kullanılmadığını onayladığınızda yaptığınız işleme benzer:
Önceki sürümler ve bazı API'ler konum izni gerektirir
Uygulamanız Android 13 veya sonraki sürümleri hedeflese bile çeşitli kablosuz API'leri için ACCESS_FINE_LOCATION izni gerekir. Örnek olarak WifiManager sınıfındaki aşağıdaki yöntemler verilebilir:
Ayrıca, NEARBY_WIFI_DEVICES izni yalnızca Android 13 ve sonraki sürümlerde kullanılabildiğinden uygulamanızda geriye dönük uyumluluk sağlamak için ACCESS_FINE_LOCATION ile ilgili tüm bildirimleri tutmanız gerekir. Ancak uygulamanız başka bir şekilde kesin konum bilgisine dayanmadığı sürece, bu iznin maksimum SDK sürümünü aşağıdaki kod snippet'inde gösterildiği gibi 32 olarak ayarlayabilirsiniz:
Uygulamanız Android 13 veya sonraki sürümleri hedefliyorsa aşağıdaki kablosuz ağ API'lerinden herhangi birini çağırmak için NEARBY_WIFI_DEVICES iznini beyan etmeniz gerekir:
Şekil 1'de, Android 13 veya sonraki sürümleri hedefleyen uygulamalar için Android 13 veya sonraki sürümlerin yüklü olduğu cihazlarda Wi-Fi erişim iş akışı gösterilmektedir. Uygulamanızın, kablosuz cihaz bilgilerinden fiziksel konum elde etmediğini beyan ettiğiniz sürece ACCESS_FINE_LOCATION iznini artık bildirmeniz gerekmediğini unutmayın:
1. şekil. Android 13 (API düzeyi 33) veya sonraki sürümleri hedefleyen bir uygulamanın Wi-Fi bilgilerine erişip erişemeyeceğini belirlemeye yönelik akış şeması.
Şekil 2'de, 12L veya daha eski sürümlerin yüklü olduğu cihazlarda Wi-Fi erişimi iş akışı gösterilmektedir. ACCESS_FINE_LOCATION izninin kullanıldığını unutmayın.
Şekil 2. 12L (API düzeyi 32) veya önceki sürümleri hedefleyen bir uygulamanın Wi-Fi bilgilerine erişip erişemeyeceğini belirlemeye yönelik akış şeması
Bu sayfadaki içerik ve kod örnekleri, İçerik Lisansı sayfasında açıklanan lisanslara tabidir. Java ve OpenJDK, Oracle ve/veya satış ortaklarının tescilli ticari markasıdır.
Son güncelleme tarihi: 2025-08-27 UTC.
[null,null,["Son güncelleme tarihi: 2025-08-27 UTC."],[],[],null,["Apps that target Android 13 (API level 33) or higher and manage Wi-Fi connections\nshould request the\n[`NEARBY_WIFI_DEVICES`](/reference/android/Manifest.permission#NEARBY_WIFI_DEVICES)\n[runtime permission](/guide/topics/permissions/overview#runtime). This\npermission makes it easier to justify an app's access of nearby Wi-Fi devices;\non previous versions of Android, these apps needed to declare the\n[`ACCESS_FINE_LOCATION`](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION)\npermission instead.\n| **Caution:** If your app tries to call a Wi-Fi API without the proper permission, a [`SecurityException`](/reference/java/lang/SecurityException) occurs.\n\nPermission is part of the nearby devices group\n\nThe `NEARBY_WIFI_DEVICES` permission is part of the **Nearby devices**\npermission group. This group, added in Android 12 (API level 31), also includes\npermissions related to Bluetooth and Ultra-wideband. When you request any\ncombination of permissions from this permission group, the system shows a single\nruntime dialog and asks the user to approve your app's access to nearby devices.\nIn system settings, the user must enable and disable the **Nearby devices**\npermissions as a group; for example, users can't disable Wi-Fi access but keep\nBluetooth access enabled for a given app.\n\nStrongly assert that your app doesn't derive physical location\n\nWhen you target Android 13 or higher, consider whether your app\never derives location information from Wi-Fi APIs; if not, you should strongly\nassert that. To make this assertion, set the `usesPermissionFlags` attribute to\n`neverForLocation` in your app's manifest file, as shown in the following code\nsnippet. This process is similar to the one you do when you\n[assert that Bluetooth device information is never used for location](/guide/topics/connectivity/bluetooth/permissions#assert-never-for-location): \n\n```xml\n\u003cmanifest ...\u003e\n \u003cuses-permission android:name=\"android.permission.NEARBY_WIFI_DEVICES\"\n android:usesPermissionFlags=\"neverForLocation\" /\u003e\n \u003capplication ...\u003e\n ...\n \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nPrevious versions and some APIs require location permission\n\nSeveral Wi-Fi APIs require the `ACCESS_FINE_LOCATION` permission, even when your\napp targets Android 13 or higher. Examples include the following\nmethods from the `WifiManager` class:\n\n- [`getScanResults()`](/reference/android/net/wifi/WifiManager#getScanResults())\n- [`startScan()`](/reference/android/net/wifi/WifiManager#startScan())\n\nAlso, because the `NEARBY_WIFI_DEVICES` permission is available only on\nAndroid 13 and higher, you should keep any declarations for\n[`ACCESS_FINE_LOCATION`](/reference/android/Manifest.permission#ACCESS_FINE_LOCATION)\nto provide backward compatibility in your app. However, as long as your app\ndoesn't otherwise rely on\n[precise location information](/training/location/permissions#accuracy), you can\nset the maximum SDK version of this permission to `32`, as shown in the\nfollowing code snippet: \n\n```xml\n\u003cmanifest ...\u003e\n \u003cuses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"\n android:maxSdkVersion=\"32\" /\u003e\n \u003capplication ...\u003e\n ...\n \u003c/application\u003e\n\u003c/manifest\u003e\n```\n\nCheck for APIs that require the permission\n\nIf your app targets Android 13 or higher, you must declare the\n`NEARBY_WIFI_DEVICES` permission to call any of the following Wi-Fi APIs:\n\n- `WifiManager`\n - [`startLocalOnlyHotspot()`](/reference/android/net/wifi/WifiManager#startLocalOnlyHotspot(android.net.wifi.WifiManager.LocalOnlyHotspotCallback,%20android.os.Handler))\n- `WifiAwareManager`\n - [`attach(AttachCallback attachCallback,\n IdentityChangedListener identityChangedListener,\n Handler handler)`](/reference/android/net/wifi/aware/WifiAwareManager#attach(android.net.wifi.aware.AttachCallback,%20android.net.wifi.aware.IdentityChangedListener,%20android.os.Handler))\n- `WifiAwareSession`\n - [`publish()`](/reference/android/net/wifi/aware/WifiAwareSession#publish(android.net.wifi.aware.PublishConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler))\n - [`subscribe()`](/reference/android/net/wifi/aware/WifiAwareSession#subscribe(android.net.wifi.aware.SubscribeConfig,%20android.net.wifi.aware.DiscoverySessionCallback,%20android.os.Handler))\n- `WifiP2pManager`\n - [`addLocalService()`](/reference/android/net/wifi/p2p/WifiP2pManager#addLocalService(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.nsd.WifiP2pServiceInfo,%20android.net.wifi.p2p.WifiP2pManager.ActionListener))\n - [`connect()`](/reference/android/net/wifi/p2p/WifiP2pManager#connect(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pConfig,%20android.net.wifi.p2p.WifiP2pManager.ActionListener))\n - [`createGroup()`](/reference/android/net/wifi/p2p/WifiP2pManager#createGroup(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pConfig,%20android.net.wifi.p2p.WifiP2pManager.ActionListener))\n - [`discoverPeers()`](/reference/android/net/wifi/p2p/WifiP2pManager#discoverPeers(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.ActionListener))\n - [`discoverServices()`](/reference/android/net/wifi/p2p/WifiP2pManager#discoverServices(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.ActionListener))\n - [`requestDeviceInfo()`](/reference/android/net/wifi/p2p/WifiP2pManager#requestDeviceInfo(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.DeviceInfoListener))\n - [`requestGroupInfo()`](/reference/android/net/wifi/p2p/WifiP2pManager#requestGroupInfo(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.GroupInfoListener))\n - [`requestPeers()`](/reference/android/net/wifi/p2p/WifiP2pManager#requestPeers(android.net.wifi.p2p.WifiP2pManager.Channel,%20android.net.wifi.p2p.WifiP2pManager.PeerListListener))\n- `WifiRttManager`\n - [`startRanging()`](/reference/android/net/wifi/rtt/WifiRttManager#startRanging(android.net.wifi.rtt.RangingRequest,%20java.util.concurrent.Executor,%20android.net.wifi.rtt.RangingResultCallback))\n\nWi-Fi access workflows\n\nFigure 1 shows the Wi-Fi access workflow on devices that run\nAndroid 13 or higher, for apps that target\nAndroid 13 or higher. Note that, as long as you assert that your\napp doesn't derive physical location from Wi-Fi device information, you don't\nneed to declare the `ACCESS_FINE_LOCATION` permission anymore:\n**Figure 1.** Flow chart to determine whether an app that targets Android 13 (API level 33) or higher can access Wi-Fi information.\n\nFigure 2 shows the Wi-Fi access workflow on devices that run\n12L or lower. Note the reliance on the\n`ACCESS_FINE_LOCATION` permission.\n**Figure 2.** Flow chart to determine whether an app that targets 12L (API level 32) or lower can access Wi-Fi information."]]