Reputation: 99
How to get the name of device which connect from hotspot(server)?
One hotspot connect many device but nothing to get name of connected device, How to get it?
I can easy to get IP Address but how to get name?
Upvotes: 1
Views: 956
Reputation: 1667
The below method will work but, this is detecting the version 4.0 and above; it is not able to find the devices with version 2.2 or 2.3 which is connected with hotspot.
public void getClientList() {
int macCount = 0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("/proc/net/arp"));
String line;
while ((line = br.readLine()) != null) {
String[] splitted = line.split(" +");
if (splitted != null ) {
// Basic sanity check
String mac = splitted[3];
System.out.println("Mac : Outside If "+ mac );
if (mac.matches("..:..:..:..:..:..")) {
macCount++;
/* ClientList.add("Client(" + macCount + ")");
IpAddr.add(splitted[0]);
HWAddr.add(splitted[3]);
Device.add(splitted[5]);*/
System.out.println("Mac : "+ mac + " IP Address : "+splitted[0] );
System.out.println("Mac_Count " + macCount + " MAC_ADDRESS "+ mac);
Toast.makeText(
getApplicationContext(),
"Mac_Count " + macCount + " MAC_ADDRESS "
+ mac, Toast.LENGTH_SHORT).show();
}
/* for (int i = 0; i < splitted.length; i++)
System.out.println("Addressssssss "+ splitted[i]);*/
}
}
} catch(Exception e) {
}
}
==>Check here :
Check requestPeers of WifiP2pManager
As per documents it seeks PeerListListener which returns WifiP2pDeviceList carrying list of WifiP2pDevice which carries deviceAddress, deviceName, primaryDeviceType, secondaryDeviceType, status and other attributes.
Upvotes: 1