安卓何时广播WIFI_P2P_STATE_CHANGED_ACTION

时间:2019-07-07 02:44:20

标签: android wifi-direct

我是android新手,当我运行android WifiP2pConnectDemo时,程序正常工作。在BroadcastReceiver中,WIFI_P2P_STATE_CHANGED_ACTION打算调用wifiManager.discoverPeers()。但是当剂量Android广播此意图时,我找不到启用wifi-direct的代码?

Android 8

public class WifiP2pBroadcastReceiver extends BroadcastReceiver {
...
 @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        if(WifiP2pManager.WIFI_P2P_STATE_CHANGED_ACTION.equals(action)) {
           WifiP2pManager.discoverPeers(...);
        } 
}
...
}

0 个答案:

没有答案