title: Get Wifi Interface name on Android
body: <p>I am currently developing a sort of wifi sniffer. To achieve that I use a tcpdump binary compiled for arm. But it's assume that I know the name of the Wifi Interface.</p>
  
  <p>According to the SDK documentation <a href="http://developer.android.com/reference/java/net/NetworkInterface.html" rel="nofollow noreferrer">NetworkInterface</a> provide a getName() method.<br>
  I plan to use this method, so the first step is to get the NetworkInterface objet corresponding to my wifi interface.<br>
  To do that I use the WifiInfo to get the ip adress, then get an InetAddress corresponding to this IP and finally get an instance of NetworkInterface by using the static method getByInetAddress(InetAddress address).</p>
  
  <p>Here is my code :</p>
  
  <pre><code>WifiInfo wifiInfo = wifiManager.getConnectionInfo();
  int ipAddress = wifiInfo.getIpAddress();
  byte[] bytes = BigInteger.valueOf(ipAddress).toByteArray();
  InetAddress addr = InetAddress.getByAddress(bytes);
  NetworkInterface netInterface = NetworkInterface.getByInetAddress(addr);
  Log.e("MyTemp",netInterface.getName());
  </code></pre>
  
  <p>The output :</p>
  
  <pre><code>SSID: Nancy-Universite, BSSID: 00:19:30:6a:a9:40, MAC: B4:07:F9:D5:7C:8C, Supplicant    state: COMPLETED, RSSI: -80, Link speed: 11, Net ID: 6
  </code></pre>
  
  <p>But I except something like :</p>
  
  <pre><code>eth0
  </code></pre>
  
  <p>I also try the isVirtual() method but it doesn't compile, and I get an error message saying the method isVirtual() is not define for the type NetworkInterface.
  I don't understand what is going on...<br>
  Any help will be appreciate.</p>