检测连接到 Wifi 的 Android 设备
我想制作一个连接到 Wifi 网络的 Android 应用程序,假设网络 SSID =“ABC”。假设它已连接到 Wifi ABC。连接到 ABC 后,我希望我的应用程序显示连接到同一 wifi ABC 网络的所有 Android 设备的 ip。我怎样才能做到这一点?谢谢
I want to make an android application that connects to a Wifi network, say network SSID = "ABC".Assume that it is connected to the Wifi ABC. After connecting to ABC, i would want my application to display the ips of all the android devices that are connected to the same wifi ABC network. How can i achieve that? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看手机上的文件:/proc/net/arp。
它具有连接到同一网络的所有其他设备的 IP 和 MAC 地址。不过我担心你无法区分它们是否是安卓手机。
Check out the file: /proc/net/arp on your phone.
It has the ip and MAC addreses of all the other devices connected to the same network. However I am affraid you wont be able to differentiate if they are android phones or not.
您将需要使用 tcpdump 将网卡置于混杂模式,然后捕获数据包以识别网络上的其他客户端。
如何在 Android 上使用 tcpdump:
http://source.android.com/porting/tcpdump.html
您可以运行命令在你的代码中像这样:
You will want to use tcpdump to put the network card into promiscous mode and then capture packets to identify what other clients are on your network.
How to use tcpdump on android:
http://source.android.com/porting/tcpdump.html
You can run commands in your code like so: