Skip to content

Instantly share code, notes, and snippets.

@davinctor
Forked from tiwiz/AddWifiNetwork.java
Created February 13, 2017 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davinctor/3a8c47fe5f9a1d0bf8b362c0ee130f27 to your computer and use it in GitHub Desktop.
Save davinctor/3a8c47fe5f9a1d0bf8b362c0ee130f27 to your computer and use it in GitHub Desktop.
Add your Wi-Fi Network to Android Things
String networkSSID = "Your Network SSID here";
String networkPasskey = "YourNetworkPasswordHere";
WifiConfiguration wifiConfiguration = new WifiConfiguration();
wifiConfiguration.SSID = "\"" + networkSSID + "\"";
wifiConfiguration.preSharedKey = "\"" + networkPasskey + "\"";
WifiManager manager = (WifiManager) getSystemService(WIFI_SERVICE);
manager.addNetwork(wifiConfiguration);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment