手机设备连接3G网络时,如何判断安卓设备的ip地址是否公开?
public static InetAddress getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress address = enumIpAddr.nextElement();
return address;
}
}
} catch (SocketException ex) {
Log.e(DEBUG_TAG, ex.toString());
}
return null;
}