title: Get IPconfig info android
body: <p>Im developing an android app, and one of the activities shows an IPconfig list. I am using the following code for getting the info:</p>
  
  <pre><code>public String   s_dns1 ;
      public String   s_dns2;     
      public String   s_gateway;  
      public String   s_ipAddress;    
      public String   s_leaseDuration;    
      public String   s_netmask;  
      public String   s_serverAddress;
      DhcpInfo d;
      WifiManager wifii;
  
   wifii= (WifiManager) getSystemService(Context.WIFI_SERVICE);
          d=wifii.getDhcpInfo();
          s_dns1="DNS 1: "+String.valueOf(d.dns1);
          s_dns2="DNS 2: "+String.valueOf(d.dns2);    
          s_gateway="Default Gateway: "+String.valueOf(d.gateway);    
          s_ipAddress="IP Address: "+String.valueOf(d.ipAddress); 
          s_leaseDuration="Lease Time: "+String.valueOf(d.leaseDuration);     
          s_netmask="Subnet Mask: "+String.valueOf(d.netmask);    
          s_serverAddress="Server IP: "+String.valueOf(d.serverAddress);
  
          info= (TextView) findViewById(R.id.info1);
          info.setText("\n"+s_dns1+"\n"+s_dns2+"\n"+s_gateway+"\n"+s_ipAddress+"\n"+s_leaseDuration+"\n"+s_netmask+"\n"+s_serverAddress);
  </code></pre>
  
  <p>In the emulator i get the following:</p>
  
  <pre><code>DNS1:0
  DNS2:0
  Default gateway:0
  IP address:0
  Lease time:0
  Subnet mask:-1
  Server IP:0
  </code></pre>
  
  <p>However, when i test the APK on my Galaxy tab GT-P1000 i get the following:</p>
  
  <pre><code>DNS1:16820416
  DNS2:0
  Default gateway:16820416
  IP address:33597632
  Lease time:86400
  Subnet mask:16777215
  Server IP:16820416
  </code></pre>
  
  <p>What am i doing wrong?</p>
  
  <p>Thanks.</p>