Newbie needs help: outputting getDisplayName()
<p>Sorry if that sounds toooo newbie. I am not new to programming, but I am definitely new to (tags: object-oriented programming, java, Android).</p>

<p>So here's the source code that a dummy app that I am currently working on. The aim of code below are to fetch the name of the Wi-Fi interface (eg. wlan0) and output it via a textview.</p>

<pre><code>package com.helloworld;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Enumeration;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

public class SpoofActivity extends Activity {
    private TextView tvOrigMacAddr;
    private TextView tvCurrMacAddr;
    protected NetworkInterface wifiInterface;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    //some stuff here
    }

    public void ClickHandler(View v)
    {
        WifiManager wifiManager = (WifiManager) this.getSystemService(Context.WIFI_SERVICE);
        wifiInterface = getWifiNetworkInterface(wifiManager);
        tvWifiNICName = (TextView) findViewById(R.id.tvWifiNICName);
        tvWifiNICName.setText(wifiInterface.getDisplayName());      
    }
    public static NetworkInterface getWifiNetworkInterface(WifiManager manager) {
        //taken from http://www.gubatron.com/blog/2010/09/19/android-programming-how-to-obtain-the-wifis-corresponding-networkinterface/. I don't even know if I've placed it in the right block.
        Enumeration&lt;NetworkInterface&gt; interfaces = null;
        try {
            interfaces = NetworkInterface.getNetworkInterfaces();
        } catch (SocketException e) {
            return null;
        }
        int wifiIP = manager.getConnectionInfo().getIpAddress();
        int reverseWifiIP = Integer.reverseBytes(wifiIP);
        while (interfaces.hasMoreElements()) {
            NetworkInterface iface = interfaces.nextElement();
            Enumeration&lt;InetAddress&gt; inetAddresses = iface.getInetAddresses();
                while (inetAddresses.hasMoreElements()) {
                InetAddress nextElement = inetAddresses.nextElement();
                int byteArrayToInt = byteArrayToInt(nextElement.getAddress(),0);
                if (byteArrayToInt == wifiIP || byteArrayToInt == reverseWifiIP) {
                    return iface;
                }
                }
        }
        return null;
    }
    public static final int byteArrayToInt(byte[] arr, int offset) {
        if (arr == null || arr.length - offset &lt; 4)
            return -1;

        int r0 = (arr[offset] &amp; 0xFF) &lt;&lt; 24;
        int r1 = (arr[offset + 1] &amp; 0xFF) &lt;&lt; 16;
        int r2 = (arr[offset + 2] &amp; 0xFF) &lt;&lt; 8;
        int r3 = arr[offset + 3] &amp; 0xFF;
        return r0 + r1 + r2 + r3;
    }

}
</code></pre>

<p>Upon execution of the code above (ie. triggered by clicking the button), the app will be FC'ed.</p>

<p>Thanks for your help.</p>
