I'm trying to create an app that can tell you the signal strength of a wifi access point it's currently connected to. I'm using Android Studios and am a beginner. How do I retrieve this information? Any methods would be helpful.
我正在尝试创建一个可以告诉你当前连接的wifi接入点信号强度的应用。我正在使用Android Studios并且是初学者。如何检索此信息?任何方法都会有所帮助。
1 个解决方案
#1
public void onReceive(WifiManager wifiManager) {
int numberOfLevels=5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level=WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
System.out.println("Bars =" +level);
}
#1
public void onReceive(WifiManager wifiManager) {
int numberOfLevels=5;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int level=WifiManager.calculateSignalLevel(wifiInfo.getRssi(), numberOfLevels);
System.out.println("Bars =" +level);
}