Android Why am I receiving a "thread exiting with uncaught exception”?

The thing im trying to implement is a onclick for my listview so when i click in my listview in tab1 i want to switchtabs to tab2 and then i want to save the clicked listview row to be displayed in same listview in tab2 but with more information. But im getting this error.
Why am i getting this error, and how can i display the choosen row in tab1 to tab2?

public class Tab1 extends TabActivity {

    WifiManager wifiManager;
    WifiScanReceiver wifiReciever;
    String ssid;
    int channel;
    int level;
    ArrayAdapter adapter;
    ListView list;
    ArrayList<String> wifis;
    WifiInfo wifiInfo;
    TabHost tabHost;

    // TabSpec Names
    private static final String TAB1 = "Tab1";
    private static final String TAB2 = "Tab2";
    private static final String TAB3 = "Tab3";

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tab1);

        list = (ListView) findViewById(R.id.text);
        wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
        wifiReciever = new WifiScanReceiver();
        wifiInfo = wifiManager.getConnectionInfo();

        wifis = new ArrayList<String>(); //initialize wifis
        wifis.add("loading...");
        adapter = new ArrayAdapter<String>(getApplicationContext(),
                android.R.layout.simple_list_item_1, wifis);
        list.setAdapter(adapter);

        wifiManager.startScan(); //make sure this is the last call
        list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
                v.findViewById(R.id.text);
                switchTab(1);
            }
        }); };

    public void switchTabs(int tab) {
        tabHost.setCurrentTab(tab);
    }

    public void switchTab(int tab) {
        tabHost.setCurrentTab(tab);
    }

    protected void onPause() {
        unregisterReceiver(wifiReciever);
        super.onPause();
    }

    public static int convertFrequencyToChannel(int freq) {
        if (freq >= 2412 && freq <= 2484) {
            return (freq - 2412) / 5 + 1;
        } else if (freq >= 5170 && freq <= 5825) {
            return (freq - 5170) / 5 + 34;
        } else {
            return -1;
        }
    }

    protected void onResume() {
        registerReceiver(wifiReciever, new IntentFilter(
                WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
        super.onResume();
    }


    class WifiScanReceiver extends BroadcastReceiver {
        @SuppressLint("UseValueOf")
        public void onReceive(Context c, Intent intent) {
            List<ScanResult> wifiScanList = wifiManager.getScanResults();
            wifis.clear(); //add this
            for (int i = 0; i < wifiScanList.size(); i++) {
                ssid = wifiScanList.get(i).SSID; //Get the SSID
                level = wifiScanList.get(i).level;
                channel = wifiScanList.get(i).frequency;

                //use add here:
                wifis.add(ssid + " " + level + " dBm "); //append to the other data
                wifis.toString();
            }

            adapter.notifyDataSetChanged(); //add this
            wifiManager.startScan(); //start a new scan to update values faster

        }
    }

}

Error messages

05-20 10:40:42.710    4694-4694/com.example.isac.tabtry W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0x41477930)
05-20 10:40:42.718    4694-4694/com.example.isac.tabtry E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.NullPointerException


Source: android

Leave a Reply