CoderRoller CoderRoller - 5 months ago 36
Android Question

WifiP2pManager discoverPeers ActionListener returns Busy

I am using WifiP2pManager class to initiate the discovery of Peers as referred here:

Part of the code goes as follows:

//Activity Class

protected void onCreate(Bundle savedInstanceState) {

mManager = (WifiP2pManager) getSystemService(Context.WIFI_P2P_SERVICE);
mChannel = mManager.initialize(this, getMainLooper(), null);

//Separate class here
mReceiver = new WiFiDirectBroadcastReceiver(mManager, mChannel, this);

//register the events to filter on to perform the broadcast receiver
mIntentFilter = new IntentFilter();


mManager.discoverPeers(mChannel, new WifiP2pManager.ActionListener() {
public void onSuccess() {
myTextView.setText("Success discovery");

public void onFailure(int reasonCode) {
myTextView.setText("Discovery errorcode:" + String.valueOf(reasonCode));


Happens that I get the
call in my phone (JellyBean based), but a Lenovo A2107A Tablet used for testing running Android 4.1.2 IceCream sandwich just get
where reasonCode equals 2 (Busy):

I noticed that in the Wifi Settings of the phone the WifiDirect discovery list option shows up, but in the tablet there is no option to do this, although the OS version 4.x supposedly supports it, programmatically at least (I tested ShareIt App and the tablet can transfer files through WiFi).

A similar question has been made here: Why do I always get BUSY when using WifiP2pManager? but with no accepted answer.

Is there anything I can do to avoid the always busy state while using this API method on the Tablet?. Thanks!


Apparently the Lenovo A2107A tablet returning "Busy" state after calling the WifiP2pManager instance on its discoveryPeers method, doesn't support WiFi Direct/WiFi P2P, in fact there is no option to lookup for P2P peers on it, hence returning the statusCode 2 Busy status in the onFailure callback, even running Android 4.1.2 that in theory does support WifiDirect which is a bit strange.

A couple of helpful projects to understand better the inner workings of this technology are here: