2

我想找到通过 USB 连接到安卓设备的台式电脑的 IP 地址。在堆栈溢出的每个线程和我发现返回设备 IP 地址的任何其他网站中。但我想要连接到 android 设备的台式电脑的 IP 地址。

有没有可用的Android API?

4

2 回答 2

0

I don't this is possible, in general.

  • If the phone is connected as a mass storage device, I'm pretty sure (without looking at the spec) that the USB mass storage device class does not include this information. Why would it? It makes no sense.
  • The very idea of "the IP address" is a bit off; a computer can have any number of IP addresses, not just one. Think of computers with several network cards.

You might be able to implement something using a custom connection type, if possible on your phone, but then it would likely need PC-side support too.

于 2013-01-04T09:21:47.330 回答
0

你的朋友是arp。具体来说,您可以读取/proc/net/arp具有以下格式的文件

IP address       HW type     Flags       HW address            Mask     Device
192.168.1.249    0x1         0x2         00:08:9b:bf:a9:fc     *        eth0
192.168.1.252    0x1         0x2         00:0d:a2:01:15:ed     *        eth0
192.168.1.172    0x1         0x0         00:00:00:00:00:00     *        eth0

干杯,

于 2013-01-04T09:22:50.247 回答