How to get Wireless Router Information like Router MAC address from Android using Java? Like the screenshot below(Taken from WiFiman app from Android )
Asked
Active
Viewed 941 times
1 Answers
0
If you want to get the MAC address (BSSID) for the wifi network you are connected to then you can do the following:
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
WifiInfo info = wifiManager.getConnectionInfo();
info.getBSSID();
If you want to loop throught the available wifi networks you can do this:
WifiManager mWifiManager = (WifiManager) getApplicationContext(). getSystemService(Context.WIFI_SERVICE);
List<ScanResult> mScanResults = mWifiManager.getScanResults();
for (int i = 0; i < mScanResults.size(); i++)
try {
mScanResults.get(i).SSID; // the access point name (SSID)
mScanResults.get(i).BSSID; // the access point MAC (BSSID)
} catch (Exception e) {
//....
}
Don't forget the required permission in you manifest:
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
EDIT: the above code works for Android below 6.. To achive it for newer devices pleace check this thread

n0ra5
- 71
- 2
-
-
I took that from an old project my bad.. I added an edit however to with a link for the newer approach – n0ra5 Aug 05 '19 at 12:16
-
Tried all the solutions in your edited link. but none of them works. I'm using 9.0.1 – xuka Aug 05 '19 at 12:23