سؤال

I have been trying to create an android application that will give me the signal strength of my home access point from a wireless device e.g. laptop, mobile phone. I have been pulling my hair out with it the last few days and been getting no where. Can someone please give a hand with this because it is really getting on my nerves :( all I want it to do at the minute is display the strength in the console for me, it sounded pretty simple and I have read countless articles and have got nowhere at all :(

هل كانت مفيدة؟

المحلول

You can get the dbm value using WifiManager.

WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
if(wifiManager.isWifiEnabled()) {
    WifiInfo wifiInfo = wifiManager.getConnectionInfo();
    if(wifiInfo != null) {
        int dbm = wifiInfo.getRssi();
    }
}

In addition to dbm, if you wish to get the percentage about the signal strength:

int strengthInPercentage = WifiManager.calculateSignalLevel(wifiInfo.getRssi(), 100);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top