3
也许我问的是错误的问题,但我似乎无法找到我在找什么,所以我会试着在这里问它而不是谷歌。Android设备的网络接口名称
基本上,我有以下代码,从中我可以收集如果我在无线上,3G或其他东西(tethering想到)。
// Iterate over all network interfaces.
for (Enumeration<NetworkInterface> en =
NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();)
{
NetworkInterface intf = en.nextElement();
// Iterate over all IP addresses in each network interface.
for (Enumeration<InetAddress> enumIPAddr =
intf.getInetAddresses(); enumIPAddr.hasMoreElements();)
{
InetAddress iNetAddress = enumIPAddr.nextElement();
// Loop back address (127.0.0.1) doesn't count as an in-use
// IP address.
if (!iNetAddress.isLoopbackAddress())
{
sLocalIP = iNetAddress.getHostAddress().toString();
sInterfaceName = intf.getName();
}
}
}
我相信这里的重要组成部分,是sInterfaceName = intf.getName();
现在在Galaxy S和Galaxy S的标签,这似乎当连接到3G时,您连接到WiFi和“pdp0”返回“的eth0”这就是说,我真的只能测试1个Galaxy S和1个Galaxy S Tab,因为他们是我唯一的Android设备。我想象网络接口名称是由设备管理器在内核的某个地方设置的。我可能会通过内核为每个设备,但我觉得有人必须已经找到这个信息了,有什么建议在哪里寻找或搜索谷歌?
有用,但不回答这个问题。他想要接口的名称,而不是当前的网络类型。 – Andy