Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPadocMonitor.java
More file actions
Latest commit
51 lines (38 loc) · 1.33 KB
/
Copy pathPadocMonitor.java
File metadata and controls
51 lines (38 loc) · 1.33 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
packagecom.react.gabriel.wbam.padoc;
importandroid.app.Service;
importandroid.bluetooth.BluetoothAdapter;
importandroid.content.Context;
importandroid.content.Intent;
importandroid.net.wifi.WifiConfiguration;
importandroid.net.wifi.WifiManager;
importandroid.os.IBinder;
importjava.util.List;
/**
* Created by gabriel on 03/06/16.
*/
publicclassPadocMonitorextendsService {
@Override
publicIBinderonBind(Intentintent) {
returnnull;
}
@Override
publicvoidonTaskRemoved(IntentrootIntent) {
super.onTaskRemoved(rootIntent);
//TODO : need to stop service advertising only instead of whole WiFi
WifiManagerwifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
//forget wifi networks
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
if(list != null){
for( WifiConfigurationi : list ) {
wifiManager.removeNetwork(i.networkId);
wifiManager.saveConfiguration();
}
}
//Disable wifi before leaving
wifiManager.setWifiEnabled(false);
//Disable bluetooth before leaving
BluetoothAdapterbluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.disable();
stopSelf();
}
}