xamarin / Essentials

Xamarin.Essentials is no longer supported. Migrate your apps to .NET MAUI, which includes Maui.Essentials.
https://aka.ms/xamarin-upgrade
Other
1.52k stars 506 forks source link

[Bug] `Connectivity.ConnectivityChanged` handler does not work when targeting API 34 on Android 14 phones / emulators. #2130

Open salvadorjesus opened 7 months ago

salvadorjesus commented 7 months ago

Description

Connectivity.ConnectivityChanged handler does not work when targeting API 34 on Android 14 phones / emulators.

Other combinations of API levels and Android versions seem to work.

This is the same bug already reported and fixed in Maui: Adding a Connectivity.ConnectivityChanged handler does not work on Android 14 #19949.

Code snippet

Adding the handler

Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;

Do not call the method:

        private async void Connectivity_ConnectivityChanged(object sender, ConnectivityChangedEventArgs e)
        {
            Console.WriteLine("Connectivity changed");
        }

Steps to Reproduce

Download and deploy the reproduction repo.

Target API 33 or run it on an Android 13 emulator. When you make changes on the connectivity (switch flight mode on and off), the line 'connectivity changed' appears on the console (expected behavior).

When compiling for API 34 and running in an Android 14 emulator, nothing appears on console (Connectivity_ConnectivityChanged is never reached).

Reproduction Link

Reproduction repo.

jfversluis commented 7 months ago

Could you try the resulting NuGet from #2132 to verify this fix works?

salvadorjesus commented 7 months ago

Could you try the resulting NuGet from #2132 to verify this fix works?

Has the nuget been generated automatically somewhere with your pull request? I have trouble compiling the nuget locally.

jfversluis commented 7 months ago

Yes you should be able to go to this page on Azure DevOps, click on the artifact that says nuget, download it and install it from a local folder.

salvadorjesus commented 7 months ago

@jfversluis , it works!

Thank you!