如何获得连接到WiFi热点客户端设备的详细信息? [英] How to get the client device details which is connected to wifi hotspot?
问题描述
我连接编程在我的Android应用程序有wifi热点的AP不同的设备,如何检测连接和断开,并在WiFi热点编程AP的客户呢?有没有在Android的API的回调事件给有关个人设备的连接或断开事件的信息?先谢谢了。
I am connecting different devices with wifi hotspot AP programatically in my android app, How can i detect the clients being connected and disconnected and to the wifi hotspot AP Programmatically ? Is there any callback event in Android API to give information regarding the connection or disconnection events of individual devices ? Thanks in advance.
推荐答案
这个方法对我的作品,但是,这是只检测4.0及以上版本。我无法找到与2.2版或2.3这是与热点连接的设备。可以u人帮助解决这个问题。先谢谢了。
This method works for me but this is detecting only version 4.0 and above. I am not able to find the devices with version 2.2 or 2.3 which is connected with hotspot. Can u guys help to resolve this is issue. Thanks in advance.
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) {
}
}
这篇关于如何获得连接到WiFi热点客户端设备的详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!