WiFi Direct on Android not working properly

后端 未结 1 1088
隐瞒了意图╮
隐瞒了意图╮ 2021-02-10 05:27

I am trying to develop an app using wifi direct in android Jelly Bean 4.1.1. If p2p is enabled I immedialtely call

mManager.discoverPeers(mChannel, actionListene         


        
1条回答
  •  失恋的感觉
    2021-02-10 05:51

    You should use the Discovering peermethod:

    manager.discoverPeers(channel, new WifiP2pManager.ActionListener() {
        @Override
        public void onSuccess() {
            ...
        }
    
        @Override
        public void onFailure(int reasonCode) {
            ...
        }
    });
    

    If the discovery process succeeds and detects peers, the system broadcasts the WIFI_P2P_PEERS_CHANGED_ACTION intent, which you can listen for in a broadcast receiver to obtain a list of peers. When your application receives the WIFI_P2P_PEERS_CHANGED_ACTION intent, you can request a list of the discovered peers with requestPeers().

    For the full example, please check: http://developer.android.com/guide/topics/connectivity/wifip2p.html#discovering

    0 讨论(0)
提交回复
热议问题