program closed unexpected when i try getConnectionInfo
<p>I'm in the process of learning the android api. However, when I try to get info about wifi my program is closing unexpectedly:</p>

<p>here is the code: </p>

<pre><code>package com.example.helloandroid;    

import java.util.List;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.content.BroadcastReceiver;
import android.content.Context;

public class HelloAndroid extends Activity {
    /** Called when the activity is first created. */

    WifiManager wifi;
    BroadcastReceiver receiver;

    TextView textStatus;
    Button buttonScan;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        tv.setText("Hello, Android");
        setContentView(tv);

        wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
     //   WifiInfo info = wifi.getConnectionInfo();
       // tv.append("\n\nWiFi Status: " + info.toString());

    }
}
</code></pre>

<p>The code above runs, but as soon as I uncomment the line:
 <code>WifiInfo info = wifi.getConnectionInfo();</code></p>

<p>It says that my program has closed unexpectedly. I'm not sure what I'm doing wrong. Any help would be appreciated.</p>

<p>I am using the simulator.</p>

<p>Thanks</p>

<p>UPDATE: if I write out the wifi obj:</p>

<pre><code>wifi = (WifiManager)getSystemService(Context.WIFI_SERVICE);
tv.append(wifi.toString());
</code></pre>

<p>the app run and tv says:</p>

<pre><code>android.net.wifi.
WifiManager@4051c960
</code></pre>

<p>UPDATE:
LogCat:</p>

<pre><code>09-22 14:56:51.387: ERROR/AndroidRuntime(408): FATAL EXCEPTION: main
09-22 14:56:51.387: ERROR/AndroidRuntime(408): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.helloandroid/com.example.helloandroid.HelloAndroid}: java.lang.SecurityException: WifiService: Neither user 10034 nor current process has android.permission.ACCESS_WIFI_STATE.
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.os.Looper.loop(Looper.java:123)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread.main(ActivityThread.java:3683)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at java.lang.reflect.Method.invoke(Method.java:507)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at dalvik.system.NativeStart.main(Native Method)
09-22 14:56:51.387: ERROR/AndroidRuntime(408): Caused by: java.lang.SecurityException: WifiService: Neither user 10034 nor current process has android.permission.ACCESS_WIFI_STATE.
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.os.Parcel.readException(Parcel.java:1322)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.os.Parcel.readException(Parcel.java:1276)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.net.wifi.IWifiManager$Stub$Proxy.getConnectionInfo(IWifiManager.java:591)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.net.wifi.WifiManager.getConnectionInfo(WifiManager.java:605)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at com.example.helloandroid.HelloAndroid.onCreate(HelloAndroid.java:35)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
09-22 14:56:51.387: ERROR/AndroidRuntime(408):     ... 11 more
</code></pre>
