Back to project page android-sms-rpc.
The source code is released under:
MIT License
If you think the Android project android-sms-rpc listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package tk.aquaxp.smsgate.util; /*ww w . j a v a 2s . c o m*/ import android.util.Log; import org.apache.http.conn.util.InetAddressUtils; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.ArrayList; import java.util.Enumeration; /** * Created by mindworm on 08/10/14. */ public abstract class NetUtils { private static final String TAG = "NetUtils"; public static ArrayList<String> getLocalIpAdresses(){ ArrayList<String> adresses = new ArrayList<String>(); try{ Enumeration<NetworkInterface> ens = NetworkInterface.getNetworkInterfaces(); while(ens.hasMoreElements()){ NetworkInterface en = ens.nextElement(); Enumeration<InetAddress> ips = en.getInetAddresses(); while(ips.hasMoreElements()){ InetAddress ip = ips.nextElement(); if(!ip.isLoopbackAddress() && InetAddressUtils.isIPv4Address(ip.getHostAddress())){ adresses.add(ip.getHostAddress()); } } } } catch (SocketException e) { Log.e(TAG, "Getting list of IP adresses", e); //e.printStackTrace(); } return adresses; } }