无线网络直接端到端连接同行在Android? [英] wifi-direct end connection to peer on Android?

查看:267
本文介绍了无线网络直接端到端连接同行在Android?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,以结束WiFi的直接向对等连接?
我试图cancelConnect和removeGroup。他们两个返回忙?谢谢。

Is there any way to end the connection to a peer over Wifi-Direct? I tried cancelConnect and removeGroup. Both of them returned Busy? thanks.

推荐答案

这是我使用从同行断开方法。我从日志中注意到,建于应用程序在Android还使用断开同行同样的方法。

this is the method I am using to disconnect from peer. I noticed from logs that the android built in app also uses the same method to disconnect the peers.

public static void disconnect() {
    if (mManager != null && mChannel != null) {
        mManager.requestGroupInfo(mChannel, new GroupInfoListener() {
            @Override
            public void onGroupInfoAvailable(WifiP2pGroup group) {
                if (group != null && mManager != null && mChannel != null
                        && group.isGroupOwner()) {
                    mManager.removeGroup(mChannel, new ActionListener() {

                        @Override
                        public void onSuccess() {
                            Log.d(TAG, "removeGroup onSuccess -");
                        }

                        @Override
                        public void onFailure(int reason) {
                            Log.d(TAG, "removeGroup onFailure -" + reason);
                        }
                    });
                }
            }
        });
    }
}

这篇关于无线网络直接端到端连接同行在Android?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆