how to solve discovering other device via Wi-Fi (android API)?

馋奶兔 提交于 2019-11-27 16:19:58

I guess you did't add PeerListListener to your activity. so it won't reply.

you can try to implement PeerListListener in your activity

public class Chat1Activity extends Activity implements WifiP2pManager.PeerListListener

and override onPeerAvailable method in your activity

 @Override
  public void onPeersAvailable(WifiP2pDeviceList peers) {

   //put your code here

  }

and change requestPeers method in your Receiver

 if (mManager != null) {
            mManager.requestPeers(mChannel, mActivity);
 }

Hope this help!!

Have you check whether your device support Wifi Direct? Having a rom > 4.0 does not means it has wifi direct hardware support. Try to check that with PackageManager's API: http://developer.android.com/reference/android/content/pm/PackageManager.html#hasSystemFeature(java.lang.String)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!