I am writing an application in android studio for android Pie. I want to get wifi info.
@RequiresApi(api = Build.VERSION_CODES.S)
public String getData() {
String wifiDataTest;
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int frequency = wifiInfo.getFrequency();
int ipAddress = wifiInfo.getIpAddress();
int speed = wifiInfo.getLinkSpeed();
String ssid = wifiInfo.getSSID();
int wifiStandard = wifiInfo.getWifiStandard();
wifiDataTest = "Frequency [MHz]: " + frequency + "\nIP address: " + ipAddress
+ "\nSpeed [Mbps]: " + speed + "\nSSID: " + ssid + "\nWifi standard: " + wifiStandard;
return "WIFI\n" + wifiDataTest;
}
With int wifiStandard = wifiInfo.getWifiStandard ();
shows me the error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.sensors, PID: 11040
java.lang.NoSuchMethodError: No virtual method getWifiStandard()I in class Landroid/net/wifi/WifiInfo; or its super classes (declaration of 'android.net.wifi.WifiInfo' appears in /system/framework/framework.jar)
I have not found information about such an error anywhere. Everything before getWifiStandard ();
worked fine.
You're trying to run your app which contains the
getWifiStandard()
method that exists ONLY on Android 11 or up.Try this :