Search code examples
javaandroideclipsewifiwifi-direct

Intent for device list in Wi-fi direct android


I have enabled wifi through code ...

wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE); 
        wifiManager.setWifiEnabled(true);

I want to redirect to the Available devices in the wi-fi direct screen. I dont wanna implement my own listview for devices and stuff, as shown in the Wi-fi direct demo on android sdk.
enter image description here

This has been done in an app on PlayStore, where the app redirects to the devices screen and the file transfer begins on selecting a device, just like bluetooth. Whats the intent for this?


Solution

  • First of all the code you used doesn't start wifi-direct . it starts Legacy-wifi of your device . So unless the wifi-direct is enabled you can't find wifi-direct peers.

    You can skip showing the list view if you know which device you want to connect to just connect to it using it's mac, though even in this case you'd have to discover the peers (i.e call discoverPeers() of WifiP2pManager) before you connect to the device by its mac.

    Is this what you asked for or something else?