Android WiFi P2P remove group

I want to connect a device from one device to another. Therefore, what I want to do is to check whether the device is connected if (mydevice. Status = = 0). If it is connected, delete the group manager. Removegroup (channel, new actionlistener()

The problem here is that after doing this several times, the method removegroup() goes to onfailure() and the following error occurs: disconnection failed. Reason: 2 means "busy"

How to prevent the frame from being busy? Is there an appropriate way to disconnect between two devices in order to start a new connection to another device without any problems?

resolvent:

WiFi P2P creates a persistent group every time a new group is created. Therefore, only removegroup() does not work properly. You will have to use the deletepersistantgroup method (hidden). Call this method using reflection:

    private void deletePersistentGroups(){
    try {
        Method[] methods = wifip2pManager.class.getmethods();
        for (int i = 0; i < methods.length; i++) {
            if (methods[i].getName().equals("deletePersistentGroup")) {
                // Delete any persistent group
                for (int netid = 0; netid < 32; netid++) {
                    methods[i].invoke(manager, channel, netid, null);
                }
            }
        }
    } catch(Exception e) {
        e.printStackTrace();
    }
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>