We are about to switch to a new forum software. Until then we have removed the registration on this forum.
import android.net.wifi.*;
import android.content.*;
import java.util.*;
Context context;
void connect_to_wifi(){
//create wifi connection
String networkSSID = "";
String networkPass = "";
WifiConfiguration conf = new WifiConfiguration();
conf.SSID = "\"" + networkSSID + "\""; // Please note the quotes. String should contain ssid in quotes
//For WPA network you need to add passphrase like this:
conf.preSharedKey = "\""+ networkPass +"\"";
//Then, you need to add it to Android wifi manager settings:
WifiManager wifiManager = (WifiManager)context.getSystemService(Context.WIFI_SERVICE);
wifiManager.addNetwork(conf);
//And finally, you might need to enable it, so Android conntects to it:
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
for( WifiConfiguration i : list ) {
if(i.SSID != null && i.SSID.equals("\"" + networkSSID + "\"")) {
wifiManager.disconnect();
wifiManager.enableNetwork(i.networkId, true);
wifiManager.reconnect();
break;
}
}
}
void setup() {
size(480,800);
noStroke();
fill(255);
rectMode(CENTER); // This sets all rectangles to draw from the center point
connect_to_wifi();
}
void draw() {
background(#FF9900);
rect(width/2, height/2, 150, 150);
}
Error Message : FATAL EXCEPTION: Animation Thread Please solve the problem. Help.