-
Notifications
You must be signed in to change notification settings - Fork 0
/
PadocMonitor.java
51 lines (38 loc) · 1.33 KB
/
PadocMonitor.java
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
package com.react.gabriel.wbam.padoc;
import android.app.Service;
import android.bluetooth.BluetoothAdapter;
import android.content.Context;
import android.content.Intent;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiManager;
import android.os.IBinder;
import java.util.List;
/**
* Created by gabriel on 03/06/16.
*/
public class PadocMonitor extends Service {
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onTaskRemoved(Intent rootIntent) {
super.onTaskRemoved(rootIntent);
//TODO : need to stop service advertising only instead of whole WiFi
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
//forget wifi networks
List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
if(list != null){
for( WifiConfiguration i : list ) {
wifiManager.removeNetwork(i.networkId);
wifiManager.saveConfiguration();
}
}
//Disable wifi before leaving
wifiManager.setWifiEnabled(false);
//Disable bluetooth before leaving
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
bluetoothAdapter.disable();
stopSelf();
}
}