Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/228.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
wifi搜索连接到同一网络的设备,即接入点以外的设备(适用于android)_Android_Android Wifi_Wifimanager - Fatal编程技术网

wifi搜索连接到同一网络的设备,即接入点以外的设备(适用于android)

wifi搜索连接到同一网络的设备,即接入点以外的设备(适用于android),android,android-wifi,wifimanager,Android,Android Wifi,Wifimanager,我想对我的项目进行修改,目前项目状态为。。。。。 它可以搜索可用的WiFi网络并显示包含网络信息的列表。这可以正常工作。现在我想搜索并查看连接到网络的设备的详细信息。 有没有办法找到这些设备? 你的评论对我很有用,谢谢 是否要查找特定设备?或者您需要所有已连接设备的列表?第二个我认为是不可能的 编辑 发现特定设备: 使用UDP广播。可以找到一些参考资料 有些设备(路由器、硬盘等)支持某些协议,如 如果您在想要发现的设备上开发软件,您可以创建一个侦听特定端口的UDP服务器。 您的客户端将在该端口上

我想对我的项目进行修改,目前项目状态为。。。。。 它可以搜索可用的WiFi网络并显示包含网络信息的列表。这可以正常工作。现在我想搜索并查看连接到网络的设备的详细信息。 有没有办法找到这些设备?
你的评论对我很有用,谢谢

是否要查找特定设备?或者您需要所有已连接设备的列表?第二个我认为是不可能的

编辑

发现特定设备:
使用
UDP广播
。可以找到一些参考资料

有些设备(路由器、硬盘等)支持某些协议,如

如果您在想要发现的设备上开发软件,您可以创建一个侦听特定端口的
UDP
服务器。 您的客户端将在该端口上发送一条
广播
消息,而
服务器
将发送一条包含您所需信息的响应。
这是一个简单的示例。

是否要查找特定的设备?或者您需要所有已连接设备的列表?第二个我认为是不可能的

编辑

发现特定设备:
使用
UDP广播
。可以找到一些参考资料

有些设备(路由器、硬盘等)支持某些协议,如

如果您在想要发现的设备上开发软件,您可以创建一个侦听特定端口的
UDP
服务器。 您的客户端将在该端口上发送一条
广播
消息,而
服务器
将发送一条包含您所需信息的响应。
这是一个简单的例子。

您可以在IP范围上循环,并“ping”它们。 这不是最好/最快的方法(UDP更好),但在许多情况下都可以使用。 下面的示例代码返回连接到当前网络的IP地址列表

private int LoopCurrentIP = 0;

public ArrayList<InetAddress> getConnectedDevices(String YourPhoneIPAddress) {
    ArrayList<InetAddress> ret = new ArrayList<InetAddress>();

    LoopCurrentIP = 0;

    String IPAddress = "";
    String[] myIPArray = YourPhoneIPAddress.split("\\.");
    InetAddress currentPingAddr;

    for (int i = 0; i <= 255; i++) {
        try {

            // build the next IP address
            currentPingAddr = InetAddress.getByName(myIPArray[0] + "." +
                    myIPArray[1] + "." +
                    myIPArray[2] + "." +
                    Integer.toString(LoopCurrentIP));

            // 50ms Timeout for the "ping"
            if (currentPingAddr.isReachable(50)) {

                ret.add(currentPingAddr);
            }
        } catch (UnknownHostException ex) {
        } catch (IOException ex) {
        }

        LoopCurrentIP++;
    }
    return ret;
}
private int LoopCurrentIP=0;
公共阵列列表getConnectedDevices(字符串YourPhoneIPAddress){
ArrayList ret=新的ArrayList();
LoopCurrentIP=0;
字符串IPAddress=“”;
字符串[]myIPArray=YourPhoneIPAddress.split(“\\”);
InetAddress currentPingAddr;

对于(inti=0;i,您可以在IP范围上循环,并“ping”它们。 这不是最好/最快的方法(UDP更好),但在许多情况下都可以使用。 下面的示例代码返回连接到当前网络的IP地址列表

private int LoopCurrentIP = 0;

public ArrayList<InetAddress> getConnectedDevices(String YourPhoneIPAddress) {
    ArrayList<InetAddress> ret = new ArrayList<InetAddress>();

    LoopCurrentIP = 0;

    String IPAddress = "";
    String[] myIPArray = YourPhoneIPAddress.split("\\.");
    InetAddress currentPingAddr;

    for (int i = 0; i <= 255; i++) {
        try {

            // build the next IP address
            currentPingAddr = InetAddress.getByName(myIPArray[0] + "." +
                    myIPArray[1] + "." +
                    myIPArray[2] + "." +
                    Integer.toString(LoopCurrentIP));

            // 50ms Timeout for the "ping"
            if (currentPingAddr.isReachable(50)) {

                ret.add(currentPingAddr);
            }
        } catch (UnknownHostException ex) {
        } catch (IOException ex) {
        }

        LoopCurrentIP++;
    }
    return ret;
}
private int LoopCurrentIP=0;
公共阵列列表getConnectedDevices(字符串YourPhoneIPAddress){
ArrayList ret=新的ArrayList();
LoopCurrentIP=0;
字符串IPAddress=“”;
字符串[]myIPArray=YourPhoneIPAddress.split(“\\”);
InetAddress currentPingAddr;

对于(int i=0;我是的,我想发现所有………但正如你所说的,这是不可能的。因此为了进一步移动,建议我搜索特定的设备。谢谢。嗨,Gyuri Majercsik,感谢上面的链接。我已经在eclipse上测试了它作为java应用程序,它也给了我响应。当我通过(硬核)时客户端的一条字符串消息返回一条修改过的消息。现在我不知道如何在android上测试它。嗨,Gyuri Majersik,当我浏览页面上的评论时……我按照这个过程在android上工作,我不知道如何在android上执行它。给我一些提示。谢谢。你好,Patric,看看这个s one:是的,我想发现所有……但正如你所说,这是不可能的。因此,为了进一步发展,我建议我搜索特定的设备。谢谢。嗨,Gyuri Majersik,感谢上面的链接。我已经在eclipse上测试了它作为java应用程序,它也给了我响应。当我通过时(硬核)客户端的一条字符串消息返回一条修改过的消息。现在我不知道如何在android上测试它。嗨,Gyuri Majersik,当我浏览页面上的评论时……我按照这个过程在android上工作,我不知道如何在android上执行它。给我一些提示。谢谢。你好,Patric,看看这个第一:我喜欢这个。有趣的是,你如何从0循环到255,并且在循环中有一个并行运行的额外计数器。我喜欢这个。有趣的是,你如何从0循环到255,并且在循环中有一个并行运行的额外计数器。使用AppFinder库[这里的]()你的解决方案使用AppFinder库[这里的]()你的解决方案