Is there a way I can detect all Wifi devices arround me and get signal strength from android device.
For experimental use, I would like to run an app on some android device. the app should record signal strength between each phone and the others. I would like the "connection" to be directly between the phone, without using an external router. I believe this is possible as android phone has the ability to function as Wifi router, so it may be detected by other devices. But I have no idea how to programmatically approach this.
Can anyone help? Do you think this is possible?
If you want to scan all the wifi nearby, try this
Create a wifiManager,BroadcastReceiver, and scan all the wifi using any async task, the result of scanning will get on the broadcast receiver
WifiManager wManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
// wifi Scan
new wifiScan().execute(); // call to async task
BroadcastReceiver br = new BroadcastReceiver() {
@Override
public void onReceive(Context c, Intent intent) {
wifiList = wManager.getScanResults();
for (int i = 0; i < wifiList.size(); i++) {
ScanResult scanresult = wManager.getScanResults().get(i);
ssid = scanresult.SSID;//ssid is Name of wifi (String)
bid = scanresult.BSSID;// bssid: MAC of wifi (String)
level = scanresult.level;//level: strength of wifi(int)
}
};
// Async task
public class wifiScan extends AsyncTask<Void, String, Void> {
int i = 0;
protected void onPreExecute() {
}
protected void onPostExecute(Void results) {
if (results != null) { if (i < 6) { new wifiScan().execute();
}
}
}
@Override
protected Void doInBackground(Void... params) {
registerReceiver(br, new IntentFilter(
WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
wManager.startScan();
return null;
}
}
You'll be able to communicate between two devices over wifi without a router/access point using Wifi Direct (P2P). I think this features can access from Android 4.0., Otherwise, I am not sure.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With