我是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(...);
}
}
...
}