2

I need to get the list of devices (and possible details of them as well) that are connected to the Wi-Fi which is I have connected to. I don't need to connect and chat with any of them. I'm going through this link http://developer.android.com/training/connect-devices-wirelessly/wifi-direct.html#fetch.

Is wifi p2p connection works for my requirement? How do I get the list of connected devices on the device with no Wifi-Direct feature? Do my app needs to be installed on other devices in order to use wifi p2p connection? I have tried this https://github.com/rorist/android-network-discovery but it is force closing on launch of app. I've seen same kind of apps on playstore like Fing. How did they do this?

Please help me. Thanks in advance.

user1670443
  • 461
  • 2
  • 6
  • 17

1 Answers1

0
    manager=(WifiP2pManager)getSystemService(WIFI_P2P_SERVICE);
    channel=manager.initialize(this, Looper.getMainLooper(),null);        

When PEERS CHANGE.. call..

    manager.requestPeers(channel, new WifiP2pManager.PeerListListener() {
        @Override
        public void onPeersAvailable(WifiP2pDeviceList wifiP2pDeviceList) {
            Log.e("peer num", "" + wifiP2pDeviceList.getDeviceList().size());
            devices.clear();
            devices.addAll(wifiP2pDeviceList.getDeviceList());


            for(WifiP2pDevice device:wifiP2pDeviceList.getDeviceList()){
                //Log.e("device ",device.toString());
                dnames.clear();
                daddresses.clear();
                dnames.add(device.deviceName);
                daddresses.add(device.deviceAddress);
            }

        }
    });
Vivek Av
  • 69
  • 11