本帖最后由 nitibu 于 2014-09-02 12:08:49 编辑

解决方案 »

  1.   

    这个是打开的,上面好像显示有问题:/*这里以Handler去处理耗时操作,这里是打开的*/
        private class MyHandler extends Handler {
            public MyHandler() {
                // TODO Auto-generated constructor stub
            }
             
            public MyHandler(Looper looper) {
                // TODO Auto-generated constructor stub
                super(looper);
            }
     
            @Override
            public void handleMessage(Message msg) {
                // TODO Auto-generated method stub
                try {
                    Thread.sleep(500);//做个延时,让主线程先运行一下
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                super.handleMessage(msg);
                Bundle b = msg.getData();
                if (b.getBoolean("Key1") == true) {
                    WifiConfiguration wifiConfig = MainActivity.this.CreateWifiInfo(AssignedWifi, "test12345", 3);//这里创建一个WifiConfiguration
                    MainActivity.this.addNetwork(wifiConfig);//假如netWorkId并且使能
                }
                 
            }
        }