How to get the real IP address on Android application?

android get ip address of mobile network programmatically
how to get ip address of connected device in android
get user ip address android
android inetaddress get ip address
get device ip address in android
how to get external ip address in android programmatically
how to get mobile ip address in android
programmatically get ip address

How to get the real IP address ? I use Code below, the result always be 127.0.0.1

if (getIpType(context) == IP_TYPE_WIFI) {

    WifiManager wifi_service = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    DhcpInfo dhcpInfo = wifi_service.getDhcpInfo();
    WifiInfo wifiinfo = wifi_service.getConnectionInfo();
    String ip = Formatter.formatIpAddress(dhcpInfo.ipAddress);

} else {

    Runnable IpRunnable = new Runnable() {

        @Override
        public void run() {

            InetAddress addr;
            String localIp = null;

            try {
                addr = InetAddress.getLocalHost();
                localIp = addr.getHostAddress();
            } catch (UnknownHostException e) {
            }
        }
    };

    Thread payThread = new Thread(IpRunnable);
    payThread.start();
}

Try this

public String getLocalIpAddress(){
   try {
       for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces();  
       en.hasMoreElements();) {
       NetworkInterface intf = en.nextElement();
           for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
           InetAddress inetAddress = enumIpAddr.nextElement();
                if (!inetAddress.isLoopbackAddress()) {
                return inetAddress.getHostAddress().toString();
                }
           }
       }
       } catch (Exception ex) {
          Log.e("IP Address", ex.toString());
      }
      return null;
}

source https://stackoverflow.com/a/11432695/5284441

How to get the real IP address on Android application?, Indeed, when your Android Smartphones and Tablets are connecte To get your real IP Duration: 2:31 Posted: Jul 9, 2017 Go to “Settings” and tap on “Wi-Fi” settings”. Here tap and hold on your connected network and then select ”Manage network settings”. Now check the checkbox next to “Show advanced options” and select “Static” under “IP settings”. You’ll find the router IP address under the “Gateway” section.

you cant get the public ip address through the api android applied. the method is send a request to some website which will response infomations about your public ip address, and then parse the result to get the public ip.

Get your real IP Address on an Android device, We're here to help you find your Android and iPhone IP address. Let's look at how to view Duration: 3:33 Posted: Dec 7, 2018 How to Change IP Address (Public IP) and Location on Android with PureVPN. First of all, sign up for PureVPN. Visit the PureVPN Android app page to download the Android version. Once you have installed the app on your Android device, open the app and use your PureVPN credentials to log in.

Simply use Volley to get the ip from this site

 RequestQueue queue = Volley.newRequestQueue(this);

    String urlip = "http://checkip.amazonaws.com/";

    StringRequest stringRequest = new StringRequest(Request.Method.GET, urlip, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            txtIP.setText(response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            txtIP.setText("didnt work");
        }
    });

    queue.add(stringRequest);

How to Find the IP Address of Your Android or iPhone, Learn how to change the IP address on Android devices. However, if you want to learn about your public IP address, check it on Once you have installed the app on your Android device, open the app and use your  Change your IP address instantly and easily with us, By clicking on 'Change IP' button you will get a new IP address. - The application works only over mobile data connection - will not work over a WiFi network. - Notification and Widget support to change your IP easily.

How to Change Your IP Address on an Android Phone, This example demonstrates how do I get the IP address of android ACCESS_WIFI_STATE"/> <application android:allowBackup="true"  In Java, you can use InetAddress.getLocalHost() to get the Ip Address of the current Server running the Java app and InetAddress.getHostName() to get Hostname of the current Server name. CrunchifyGetIPHostname.java

How to get the IP address of android device programmatically?, IP Tools is a powerful network tools for speed up and setup networks. Helps to quickly detecting any computer network problems, ip address detection and  You can sign In only if you already have registered otherwise you cannot navigate to the next page. Therefore, first, register yourself and then sign in using your credentials. Start your server application and copy the IP address & port of workstation from the server app. Put this required parameter into client application and hit Connect.

IP Tools: WiFi Analyzer, For example, if you want to connect an app on your PC with your Android phone, then local IP address of at least one of the devices is needed. Here's how to find  To find your phone's IP address, go to Settings > About device > Status . Your phone or tablet's IP address will be displayed with other information, such as the IMEI or Wi-Fi MAC addresses: Mobile operators and ISPs also provide a so-called public IP address. Your public IP address is: When you connect to a website, your IP address will be

Comments
  • stackoverflow.com/questions/6305918/…