Hi,
I would receive notifications when signal strength changes. I tried to create the following method and call it in the onCreate():
private void initializeWiFiListener(){
Log.i(TAG, "executing initializeWiFiListener");
String connectivity_context = Context.WIFI_SERVICE;
final WifiManager wifi = (WifiManager)getSystemService(connectivity_context);
if(!wifi.isWifiEnabled()){
if(wifi.getWifiState() != WifiManager.WIFI_STATE_ENABLING){
wifi.setWifiEnabled(true);
}
}
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context context, Intent intent) {
WifiInfo info = wifi.getConnectionInfo();
//TODO: implement methods for action handling
}
}, new IntentFilter(WifiManager.RSSI_CHANGED_ACTION));
}
I would appreciate if anyone could check if the method is written correctly. I tried to run the app, but haven't received any notifications and am not sure whether it is because the signal strength might be constant in the place I run debug or it is because something is missing.
Thanks!