Java Code Examples for com.google.zxing.client.result.WifiParsedResult#getPassword()

The following examples show how to use com.google.zxing.client.result.WifiParsedResult#getPassword() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@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;
}
 
Example 2
Source Project: android-apps   File: WifiResultHandler.java    License: MIT License 5 votes vote down vote up
@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);
  }
}
 
Example 3
@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;
}
 
Example 4
@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;
}
 
Example 5
Source Project: weex   File: WifiConfigManager.java    License: Apache License 2.0 4 votes vote down vote up
@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;
}
 
Example 6
@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;
}
 
Example 7
@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;
}
 
Example 8
Source Project: reacteu-app   File: WifiConfigManager.java    License: MIT License 4 votes vote down vote up
@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;
}
 
Example 9
@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;
}
 
Example 10
Source Project: BarcodeEye   File: WifiConfigManager.java    License: Apache License 2.0 4 votes vote down vote up
@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;
}