Android - Event handler BatteryInfoChanged unsubscribe crashes when no subscribe has happened before #18376
Labels
area-essentials
Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info
fixed-in-8.0.6
Look for this fix in 8.0.6 SR1!
migration-compatibility
Xamarin.Forms to .NET MAUI Migration, Upgrade Assistant, Try-Convert
platform/android 🤖
t/bug
Something isn't working
Milestone
Description
After migration from Xamarin Essentials to MAUI Essentials I got a NullReferenceException on unsubscribing to the event BatteryInfoChanged, because in Batter
In Xamarin Essentials there was a check in the BatteryImplementation.BatteryInfoChanged "remove" code with a variable "wasRunning". For some reason this check was removed in MAUI Essentials. And this causes my code to crash in MAUI Essentials and not in Xamarin Essentials.
The same issue will probably occur with all other events on IBattery.
Steps to Reproduce
Reproduction steps for Android (didn't test on other platforms):
Link to public reproduction project repository
No response
Version with bug
7.0.96
Is this a regression from previous behavior?
Yes, this used to work in Xamarin.Forms
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android (any version)
Did you find any workaround?
No response
Relevant log output
No response
The text was updated successfully, but these errors were encountered: