正在开发一个需要显示热点详细信息的应用程序,包括连接到热点的设备数量
我试过这个但没有奏效,
private int countNumMac()
{
int macCount =0;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader("/proc/net/arp"));
String line;
System.out.println(br.toString());
while ((line = br.readLine()) != null) {
String[] splitted = line.split(" +");
System.out.println("splitted :"+splitted);
if (splitted != null && splitted.length >= 4) {
// Basic sanity check
String mac = splitted[3];
if (mac.matches("..:..:..:..:..:..")) {
macCount++;
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if(macCount == 0)
return 0;
else
return macCount-1;
}
有没有其他方法可以计算连接到热点的设备数量..
最佳答案
您输入的代码需要root权限
看看这个库。我希望它能解决你的问题
https://github.com/nickrussler/Android-Wifi-Hotspot-Manager-Class
关于android - 如何以编程方式获取热点(AP)中的连接设备数量 [Android],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17849395/