bantucracy / ayanda

Android Library to discover nearby devices Offline
https://sabelo.mhlambi.com/projects/ayanda
44 stars 21 forks source link

Peer discovery Issue with Oreo (Android 8+) #17

Open sabzo opened 6 years ago

sabzo commented 6 years ago

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 commented 6 years ago

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

wxson7282 commented 5 years ago

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

wxson7282 commented 5 years ago

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

amos-yau commented 5 years ago

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

sabzo commented 5 years ago

@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.

chr33z commented 5 years ago

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.

sabzo commented 5 years ago

@chr33z is this for Ayanda or on another project?