Here is my code:
package hu.wifx.droid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.view.View;
import java.util.List;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiManager;

public class WifXActivity extends Activity {

        TextView mText;
        WifiManager mWifi;
        List<ScanResult> wifiList;
        StringBuilder _sb = new StringBuilder();


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Button btn1 = (Button) findViewById(R.id.btn1);
        btn1.setOnClickListener(new View.OnClickListener()
        {
                        public void onClick(View arg0)
                        {
                                // TODO Auto-generated method stub
                        StartTester();
                        }
                });
    }

    public void StartTester()
    {
        //startActivity(new Intent(this, WIfiScanner.class));
                IntentFilter i = new IntentFilter();
                i.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION);

                mText = (TextView) findViewById(R.id.mainText);
                mWifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
                registerReceiver(new BroadcastReceiver(){
                        public void onReceive(Context c, Intent i) {
                                WifiManager w = (WifiManager)
c.getSystemService(Context.WIFI_SERVICE);
                                wifiList = w.getScanResults();

                                _sb = new StringBuilder();

                                for(int m = 0; m < wifiList.size(); m++)
                                {
                                        
_sb.append((wifiList.get(m)).toString());
                                        _sb.append("\\n");
                                }

                                mText.setText(_sb);
                        }
                }, i);

                WifiManager WM = (WifiManager)
getSystemService(Context.WIFI_SERVICE);
                WM.setWifiEnabled(true);
                WM.startScan();
    }
}

No errors,
but when I start the emulator and click on button1:The application has
stopped unexpectedly. ....
Why?

Please help me!
Thanks.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to