@Override public void handleMessage(Message msg) { switch (msg.what) { case WifiApConst.ApScanResult: // 扫描Wifi列表 if (isRespond) { getWifiList(); refreshAdapter(mWifiList); } break; case WifiApConst.WiFiConnectSuccess: // 连接热点成功 String str = getString(R.string.wifiap_text_wifi_connected) + WifiUtils.getSSID(); mTvStatusInfo.setText(str); Toast.makeText(getActivity(), str, 0).show(); break; case WifiApConst.WiFiConnectError: // 连接热点错误 Toast.makeText(getActivity(), R.string.wifiap_toast_connectap_error, 0).show(); break; case WifiApConst.NetworkChanged: // Wifi状态变化 if (WifiUtils.isWifiEnabled()) { mTvStatusInfo.setText(getString(R.string.wifiap_text_wifi_1_0)); } else { mTvStatusInfo.setText(getString(R.string.wifiap_text_wifi_0)); Toast.makeText(getActivity(), R.string.wifiap_text_wifi_disconnect, 0).show(); } default: break; } }
/** 初始化控件设置 * */ protected void initAction() { if (!WifiUtils.isWifiConnect() && !WifiUtils.isWifiApEnabled()) { // 无开启热点无连接WIFI WifiUtils.OpenWifi(); } if (WifiUtils.isWifiConnect()) { // Wifi已连接 mTvStatusInfo.setText(getString(R.string.wifiap_text_wifi_connected) + WifiUtils.getSSID()); } if (WifiUtils.isWifiEnabled() && !WifiUtils.isWifiConnect()) { // Wifi已开启,未连接 mTvStatusInfo.setText(getString(R.string.wifiap_text_wifi_1_0)); } mSearchWifiThread.start(); }