Android Open Source - android-sms-rpc Net Utils






From Project

Back to project page android-sms-rpc.

License

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.

Java Source Code

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;
    }
}




Java Source Code List

tk.aquaxp.smsgate.ApplicationTest.java
tk.aquaxp.smsgate.activity.MainActivity.java
tk.aquaxp.smsgate.asynctask.TransmitTask.java
tk.aquaxp.smsgate.receiver.BootBroadcastReceiver.java
tk.aquaxp.smsgate.receiver.SMSBroadcastReceiver.java
tk.aquaxp.smsgate.restapi.APIServer.java
tk.aquaxp.smsgate.restapi.NanoHTTPD.java
tk.aquaxp.smsgate.service.RPCService.java
tk.aquaxp.smsgate.util.NetUtils.java
tk.aquaxp.smsgate.util.RPC.java