获取在android中使用wifi连接的所有用户的列表

时间:2022-04-17 16:08:49

I am trying to get list of all connected users in wifi tethering. I know that i have to read dnsmasq.leases but the question is, where can I get this file from my mobile?

我正在尝试获取所有wifi连接用户的列表。我知道我必须读dnsmasq。但问题是,我在哪里可以从我的手机上获得这个文件?

If i look at source code of wifi tethering open source app

如果我看一下wifi绑定开源应用的源代码

i get the file path in here

文件路径在这里

this.coretask.setPath(this.getApplicationContext().getFilesDir().getParent());
this.DATA_FILE_PATH+"/var/dnsmasq.leases" 

I might not be using this app for wifi tethering. So then how can i get the file location to read all connected users?

我可能不会用这个应用来做wifi。那么,如何获取文件位置以读取所有连接的用户呢?

2 个解决方案

#1


2  

Do not create a dependency of your app on some external app data.

不要在一些外部应用数据上创建应用的依赖项。

See this link to know how to get the list of connected WiFi devices.

查看此链接,了解如何获取连接的WiFi设备列表。

You can use Zero-conf bonjour protocol to discover other devices.

您可以使用零conf bonjour协议来发现其他设备。

Android application Wi-Fi device - AP connectivity

Android应用程序Wi-Fi设备- AP连接。

#2


0  

Why don't you make a new file, and catch usernames as they enter the wifi, writing to the file. Then remove names when they leave the wifi, instead of constantly checking names. Maybe check once every 10 seconds? +1 if this helps, -1 if it doesn't.

为什么不创建一个新文件,在用户进入wifi时捕获用户名,写入文件。然后在他们离开wifi时删除他们的名字,而不是不停地检查他们的名字。也许每10秒检查一次?+1如果有用,-1如果没用。

Sorry for lack of formatting, but I'm on my phone.

对不起,我没有格式化,但我在打电话。

#1


2  

Do not create a dependency of your app on some external app data.

不要在一些外部应用数据上创建应用的依赖项。

See this link to know how to get the list of connected WiFi devices.

查看此链接,了解如何获取连接的WiFi设备列表。

You can use Zero-conf bonjour protocol to discover other devices.

您可以使用零conf bonjour协议来发现其他设备。

Android application Wi-Fi device - AP connectivity

Android应用程序Wi-Fi设备- AP连接。

#2


0  

Why don't you make a new file, and catch usernames as they enter the wifi, writing to the file. Then remove names when they leave the wifi, instead of constantly checking names. Maybe check once every 10 seconds? +1 if this helps, -1 if it doesn't.

为什么不创建一个新文件,在用户进入wifi时捕获用户名,写入文件。然后在他们离开wifi时删除他们的名字,而不是不停地检查他们的名字。也许每10秒检查一次?+1如果有用,-1如果没用。

Sorry for lack of formatting, but I'm on my phone.

对不起,我没有格式化,但我在打电话。