コード例 #1
0
  /** 初始化控件设置 * */
  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();
  }
コード例 #2
0
 @Override
 public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
   ScanResult ap = mWifiList.get(position);
   if (ap.SSID.startsWith(WifiApConst.WIFI_AP_HEADER)) {
     mTvStatusInfo.setText(getString(R.string.wifiap_btn_connecting) + ap.SSID);
     // 连接网络
     boolean connFlag =
         WifiUtils.connectWifi(
             ap.SSID, WifiApConst.WIFI_AP_PASSWORD, WifiCipherType.WIFICIPHER_WPA);
     if (!connFlag) {
       mTvStatusInfo.setText(getString(R.string.wifiap_toast_connectap_error_1));
     }
   } else if (!WifiUtils.isWifiConnect() || !ap.BSSID.equals(WifiUtils.getBSSID())) {
     showDialogBluetooth(position, view);
   }
 }