com.google.zxing.client.result.WifiParsedResult#getNetworkEncryption ( )源码实例Demo

下面列出了com.google.zxing.client.result.WifiParsedResult#getNetworkEncryption ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreateView(inflater, container, savedInstanceState);

    View v = inflater.inflate(R.layout.fragment_result_wifi, container, false);
    result = (WifiParsedResult) parsedResult;

    ssid = result.getSsid();
    String encryption = result.getNetworkEncryption();
    pw = result.getPassword();

    TextView resultField = (TextView) v.findViewById(R.id.result_field_wifi);
    TextView resultFieldEncryption = (TextView) v.findViewById(R.id.result_field_wifi_encryption);
    TextView resultFieldPassword = (TextView) v.findViewById(R.id.result_field_wifi_pw);
    resultField.setText("SSID: " + ssid);
    resultFieldEncryption.setText(getString(R.string.encryption) + ": " + encryption);
    resultFieldPassword.setText("PW: " + pw);

    return v;
}
 
源代码2 项目: android-apps   文件: WifiResultHandler.java
@Override
public void handleButtonPress(int index) {
  // Get the underlying wifi config
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  if (index == 0) {
    String ssid = wifiResult.getSsid();
    String password = wifiResult.getPassword();
    String networkType = wifiResult.getNetworkEncryption();
    WifiManager wifiManager = (WifiManager) getActivity().getSystemService(Context.WIFI_SERVICE);
    Toast.makeText(getActivity(), R.string.wifi_changing_network, Toast.LENGTH_LONG).show();
    WifiConfigManager.configure(wifiManager, ssid, password, networkType);
    parent.restartPreviewAfterDelay(0L);
  }
}
 
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  return wifiResult.getSsid() + " (" + wifiResult.getNetworkEncryption() + ')';
}
 
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  return wifiResult.getSsid() + " (" + wifiResult.getNetworkEncryption() + ')';
}
 
源代码7 项目: weex   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
源代码8 项目: weex   文件: WifiResultHandler.java
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  return wifiResult.getSsid() + " (" + wifiResult.getNetworkEncryption() + ')';
}
 
源代码9 项目: Study_Android_Demo   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
源代码10 项目: Study_Android_Demo   文件: WifiResultHandler.java
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  return wifiResult.getSsid() + " (" + wifiResult.getNetworkEncryption() + ')';
}
 
源代码11 项目: barcodescanner-lib-aar   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
源代码12 项目: barcodescanner-lib-aar   文件: WifiResultHandler.java
@Override
public CharSequence getDisplayContents() {
  WifiParsedResult wifiResult = (WifiParsedResult) getResult();
  return wifiResult.getSsid() + " (" + wifiResult.getNetworkEncryption() + ')';
}
 
源代码13 项目: reacteu-app   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException iae) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && password.length() != 0) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
源代码14 项目: zxingfragmentlib   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}
 
源代码15 项目: BarcodeEye   文件: WifiConfigManager.java
@Override
protected Object doInBackground(WifiParsedResult... args) {
  WifiParsedResult theWifiResult = args[0];
  // Start WiFi, otherwise nothing will work
  if (!wifiManager.isWifiEnabled()) {
    Log.i(TAG, "Enabling wi-fi...");
    if (wifiManager.setWifiEnabled(true)) {
      Log.i(TAG, "Wi-fi enabled");
    } else {
      Log.w(TAG, "Wi-fi could not be enabled!");
      return null;
    }
    // This happens very quickly, but need to wait for it to enable. A little busy wait?
    int count = 0;
    while (!wifiManager.isWifiEnabled()) {
      if (count >= 10) {
        Log.i(TAG, "Took too long to enable wi-fi, quitting");
        return null;
      }
      Log.i(TAG, "Still waiting for wi-fi to enable...");
      try {
        Thread.sleep(1000L);
      } catch (InterruptedException ie) {
        // continue
      }
      count++;
    }
  }
  String networkTypeString = theWifiResult.getNetworkEncryption();
  NetworkType networkType;
  try {
    networkType = NetworkType.forIntentValue(networkTypeString);
  } catch (IllegalArgumentException ignored) {
    Log.w(TAG, "Bad network type; see NetworkType values: " + networkTypeString);
    return null;
  }
  if (networkType == NetworkType.NO_PASSWORD) {
    changeNetworkUnEncrypted(wifiManager, theWifiResult);
  } else {
    String password = theWifiResult.getPassword();
    if (password != null && !password.isEmpty()) {
      if (networkType == NetworkType.WEP) {
        changeNetworkWEP(wifiManager, theWifiResult);
      } else if (networkType == NetworkType.WPA) {
        changeNetworkWPA(wifiManager, theWifiResult);
      }
    }
  }
  return null;
}