Created
June 15, 2011 05:55
-
-
Save granoeste/1026558 to your computer and use it in GitHub Desktop.
[Android][WiFi]Wi-Fi Scan Results
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final WifiManager mWifiManager = (WifiManager) getSystemService(WIFI_SERVICE); | |
if(mWifiManager.getWifiState() == WifiManager.WIFI_STATE_ENABLED) { | |
// register WiFi scan results receiver | |
IntentFilter filter = new IntentFilter(); | |
filter.addAction(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION); | |
registerReceiver(new BroadcastReceiver(){ | |
@Override | |
public void onReceive(Context context, Intent intent) { | |
List<ScanResult> results = mWifiManager.getScanResults(); | |
final int N = results.size(); | |
Log.v(TAG, "Wi-Fi Scan Results ... Count:" + N); | |
for(int i=0; i < N; ++i) { | |
Log.v(TAG, " BSSID =" + results.get(i).BSSID); | |
Log.v(TAG, " SSID =" + results.get(i).SSID); | |
Log.v(TAG, " Capabilities=" + results.get(i).capabilities); | |
Log.v(TAG, " Frequency =" + results.get(i).frequency); | |
Log.v(TAG, " Level =" + results.get(i).level); | |
Log.v(TAG, "---------------"); | |
} | |
} | |
}, filter); | |
// start WiFi Scan | |
mWifiManager.startScan(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment