WifiP2pManager Connect sometimes causes multiple prompts

37
March 15, 2019, at 06:10 AM

I am writing an Android application with WiFi Direct. I create a group on one device with this line of code

_manager.CreateGroup(_channel, _createGroupActionListener);

And on another device, I connect to it (using its WiFi MAC address) with the following code:

WifiP2pConfig config = new WifiP2pConfig();
config.GroupOwnerIntent = 0; // to make sure I never get automatically elected as group owner
config.DeviceAddress = _macAddressOfGroupOwner;
config.Wps.Setup = Android.Net.Wifi.WpsInfo.Pbc;
_manager.Connect(_channel, config, _connectToDeviceListener);

Half the time it works, it prompts the device (group owner) to allow the connection, and after allowed, I can get an IP address for each connected device. But the other half of the time, after I tap "connect" to allow the connection, the prompt reappears right after. Sometimes 10 times in a row until it finally gives up (and no connection is made). Has anyone else experienced this or have any idea why or how to fix this?

I'm using Xamarin.Android, but this question is more applicable to Android in general.

READ ALSO
Firebase RecyclerView one view to another view [on hold]

Firebase RecyclerView one view to another view [on hold]

How to open one Recyclerview to another and another Recyclerview to open details of the relative list option details

50
How to wait until a bunch of calls ends to make another call

How to wait until a bunch of calls ends to make another call

I'm using RxJava and I know about concat, and I guess it does fit to me, because I want to finish first all of first call and then do the second one but I don't know how to implement it

54
Why does geocoder only return one result?

Why does geocoder only return one result?

I have searched several places, but I always get a single result and not the 5 as I assigned them, why will it?

44