I'm making a project in order to check Wi-fi connectivity ranges in my University.
My biggest problem right now is I have to check whether or not I'm connected to a new router while I walk inside the campus.
Since all routers in the school is actually part of one single internet and they have the same name when connectivity is low it just automatically connects to the closest router.
How can I identify if connected to another router in school when I change places?
Is ther some broadcaster function maybe?
答案 0 :(得分:1)
连接到其他路由器时,MAC地址会发生变化。 您可以像这样获得当前的MAC:
WifiManager wifiManager =
(WifiManager)ctx.getSystemService(Context.WIFI_SERVICE);
if (wifiManager.isWifiEnabled()) {
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress();
}
您可能需要在连接更改后进行检查。从CONNECTIVITY_ACTION广播接收器(API> 24)`
获取它