get Local Ip Address - Android Network

Android examples for Network:IP Address

Description

get Local Ip Address

Demo Code


//package com.java2s;

import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;

public class Main {
    public static int getLocalIpAddress(Context context) {
        WifiManager wifiManager = (WifiManager) context
                .getSystemService(Context.WIFI_SERVICE);
        WifiInfo wifiInfo = wifiManager.getConnectionInfo();
        return wifiInfo.getIpAddress();
    }// w w  w .j a va2  s.  c om
}

Related Tutorials