-1

How to get Wireless Router Information like Router MAC address from Android using Java? Like the screenshot below(Taken from WiFiman app from Android )

screenshot

xuka
  • 99
  • 1
  • 7

1 Answers1

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