Reputation: 1446
This method started returning null in Android P (API 28)
private String getSSID() {
final ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE)
final NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
if (networkInfo != null && networkInfo.getExtraInfo() != null) {
return StringUtils.removeQuotes(networkInfo.getExtraInfo());
}
return null;
}
Upvotes: 0
Views: 797
Reputation: 1446
This can be updated to...
private String getSSID() {
final WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
fina WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo != null && wifiInfo.getSSID() != null) {
return StringUtils.removeQuotes(wifiInfo.getSSID());
}
return null;
}
getExtraInfo()
Returns null when not available.
Based on my testing with Android P - it seems to always be null
Upvotes: 2