-
Notifications
You must be signed in to change notification settings - Fork 0
/
Enable Wifi
36 lines (31 loc) · 755 Bytes
/
Enable Wifi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Permissins needed: ACCESS_WIFI_STATE and CHANGE_WIFI_STATE
import android.net.wifi.WifiManager;
import android.content.Intent;
import android.app.Activity;
import android.content.Context;
Activity act;
Context cnt;
boolean toggle;
WifiManager wifi;
void setup() {
background(0, 0, 100);
fill(255);
size(400, 400);
textAlign(CENTER);
textSize(25);
text("Click to toggle Wifi On/Off", width/2, height/2);
act = this.getActivity();
cnt = act.getApplicationContext();
wifi = (WifiManager) cnt.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
}
void draw() {
}
void mousePressed() {
if (toggle) {
wifi.setWifiEnabled(true);
toggle = false;
} else {
wifi.setWifiEnabled(false);
toggle = true;
}
}