protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WifiManager mainWifiObj;
mainWifiObj = (WifiManager) getSystemService(Context.WIFI_SERVICE);
class WifiScanReceiver extends BroadcastReceiver {
public void onReceive(Context c, Intent intent) {
}
}
WifiScanReceiver wifiReciever = new WifiScanReceiver();
registerReceiver(wifiReciever, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
List<ScanResult> wifiScanList = mainWifiObj.getScanResults(); int signalLevel = 0; StringBuilder sb = new StringBuilder();
for (ScanResult result : wifiScanList) {
sb.append(result.level) ;
}
TextView tv = new TextView(this);
tv.setText(sb);
setContentView(tv);
This code gives me all the signal strength from the routers connected . It gives me answers as for e.g -43 -55 -66 -76 -85 -87. Now I want to access a particular routers signal strength only. Not all the 6 six routers which are connected.
How can I find the strength for a particular router ?
Can you please help me out. Thanks in advance.
Just look at the SSID:
for (ScanResult result : wifiScanList) {
if( result.SSID.equals( "TheSSIDIWant" )
Log.d( "Wifi Scan", "Signal Level for TheSSIDIWant is " + result.level );
}