was the problem itself. most of them are that you do not check if you are connected to Wi-Fi before trying to get bssid:
public static boolean isConnectedToRouter(Context context) {
ConnectivityManager onnectivityManager = (ConnectivityManager) context
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo wifi = onnectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
if (wifi.isConnected()) {
return true;
}
return false;
}
only if this method returns true, can you get bssid. to get the BSSID when you are not connected to a specific Wi-Fi, it will return 00: 00: 00: 00: 00: 00
source
share