ayanda icon indicating copy to clipboard operation
ayanda copied to clipboard

Peer discovery Issue with Oreo (Android 8+)

Open sabzo opened this issue 7 years ago • 7 comments

On Pixel 2: WifiDirect class: WifiP2pManager.PeerListListener's onPeersAvailable method fires but shows the list of devices as empty. It detects nearby devices but won't list them.

sabzo avatar Jan 23 '18 04:01 sabzo

It turns out on Android 8+ at least as it relates to the Pixel 2, Location has to be turned on in order to discover nearby devices through Wifi Direct! cc @n8fr8

Issue somewhat similar to https://stackoverflow.com/questions/32151603/scan-results-available-action-return-empty-list-in-android-6-0

sabzo avatar Jan 27 '18 00:01 sabzo

I have the same problem in my project on Android 8. If the solution is OK, please let me know. Thank you.

wxson7282 avatar Nov 12 '18 12:11 wxson7282

On Android 8+ you should get permission of ACCESS_COARSE_LOCATION, or can not get device list.

wxson7282 avatar Nov 15 '18 13:11 wxson7282

yep i found request the permission PLUS enable GPS will work.

amos-yau avatar Feb 02 '19 02:02 amos-yau

@wxson7282 @amos-yau yea -- the Android docs don't clearly cover that part. I'm resuming development soon and I'd like to add Unit Tests.

sabzo avatar Feb 02 '19 20:02 sabzo

On my OnePlus 3 (8.0.0) peer discovery only returned a result list when ACCESS_COURSE_LOCATION was granted and GPS was turned on. The wifi direct manager in the OxygenOS settings however showed an advertising peer without GPS turned on.

chr33z avatar Apr 06 '19 06:04 chr33z

@chr33z is this for Ayanda or on another project?

sabzo avatar Apr 09 '19 16:04 sabzo