6

There's no problem getting SSID in Android 9.0&8.0
but I can't get SSID in Android 10.0(Q).
How should I do? and Where is the document links about wifi in android 10.0? I tried to find the document but I couldn't find it.

There's no problem getting SSID in Android 9.0&8.0

WifiManager mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
assert mWifiManager != null;
WifiInfo info = mWifiManager.getConnectionInfo();
return info.getSSID();
ConnectivityManager connManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
assert connManager != null;
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
if (networkInfo.isConnected()) {
     if (networkInfo.getExtraInfo() != null) {
        return networkInfo.getExtraInfo().replace("\"", "");
    }
}
Vadim Kotov
  • 7,766
  • 8
  • 46
  • 61
a2633063
  • 63
  • 1
  • 3

1 Answers1

6

It want be get.check original post

From android 8.0 onwards we wont be getting SSID of the connected network unless GPS is turned on.

Get SSID when WIFI is connected

WifiManager mWifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
assert mWifiManager != null;
WifiInfo info = mWifiManager.getConnectionInfo();
return info.getSSID();
Déborah
  • 5
  • 2
Chanaka Weerasinghe
  • 4,797
  • 2
  • 23
  • 35