I'm encountering an issue with retrieving a WifiInfo object from an Intent on Android 13. I have an onReceive() function that is invoked by android.net.wifi.STATE_CHANGE.
The following code returns null on Android 13:
val wifiInfo: WifiInfo? = intent?.getParcelableExtra("wifiInfo", WifiInfo::class.java)
In the same project, I used the below code and it works as expected on Android 8.1.
val wifiInfo: WifiInfo? = intent?.getParcelableExtra<WifiInfo>("wifiInfo")
Has anyone encountered a similar issue or have any insights on why this might be happening on Android 13?
Thanks in advance for your help!
intentcoming from?onReceive(context: Context?, intent: Intent?)function that is invoked byandroid.net.wifi.STATE_CHANGE.networkInfoinstead ofwifiInfowhen you try to read the "extra". From the documentation it looks like this broadcastIntentshould contain an "extra" with that key (it is of typeNetworkInfo, notWifiInfo. Otherwise, add some logging and see what "extras" are contained in the broadcastIntent.