小弟在这里谢了!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!跪求android底层jni里面获取本地IP的方法。跪求!!

解决方案 »

  1.   

    public static String getLocalIpAddress() {   
            try {
             for (Enumeration<NetworkInterface> en = NetworkInterface  
             .getNetworkInterfaces(); en.hasMoreElements();) {  
             NetworkInterface intf = en.nextElement();  
             if (intf.getName().toLowerCase().equals("eth0") || intf.getName().toLowerCase().equals("wlan0")|| intf.getName().toLowerCase().equals("ppp0")){   
             for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {  
             InetAddress inetAddress = enumIpAddr.nextElement();  
             if (!inetAddress.isLoopbackAddress()) {  
             String ipaddress = inetAddress.getHostAddress().toString();  
             if(!ipaddress.contains("::")){//ipV6的地址  
             return ipaddress;  
             }  
             }  
             }  
             } else {  
             continue;  
             }  
             }  
            } catch (SocketException ex) {   
                Log.e("WifiPreference IpAddress", ex.toString());   
            }   
            return null;   
        } 不用JNI了。。
      

  2.   

    但是我只需要jni,我写的是个接口,写在jni里面的!