您当前的位置:首页 > 计算机 > 编程开发 > 安卓(android)开发

Andorid获取本地电话的方法

时间:04-07来源:作者:点击数:

android获取本地电话的方法:

private String getIpAddr() {
    String IP = null;
    StringBuilder IPStringBuilder = new StringBuilder();
    try {
        Enumeration<NetworkInterface> networkInterfaceEnumeration = NetworkInterface.getNetworkInterfaces();
        while (networkInterfaceEnumeration.hasMoreElements()) {
            NetworkInterface networkInterface = networkInterfaceEnumeration.nextElement();
            Enumeration<InetAddress> inetAddressEnumeration = networkInterface.getInetAddresses();
            while (inetAddressEnumeration.hasMoreElements()) {
                InetAddress inetAddress = inetAddressEnumeration.nextElement();
                if (!inetAddress.isLoopbackAddress()&&!inetAddress.isLinkLocalAddress()&&inetAddress.isSiteLocalAddress()) {
                    IPStringBuilder.append(inetAddress.getHostAddress().toString()+"\n");
                }
            }
        }
    }catch (SocketException ex) {
    }
    IP = IPStringBuilder.toString();
    return IP;
}

 

方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门