Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

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

Open
salvadorjesus opened this issue Feb 26, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@salvadorjesus
Copy link

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.

@salvadorjesus salvadorjesus added the bug Something isn't working label Feb 26, 2024
salvadorjesus added a commit to salvadorjesus/Essentials that referenced this issue Feb 26, 2024
…targeting API 34 on Android 14 phones'

Fix for xamarin#2130 based on the fix dotnet/maui#19968 for Maui for the similar issue dotnet/maui#19949.
@jfversluis
Copy link
Member

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

@salvadorjesus
Copy link
Author

salvadorjesus commented Feb 27, 2024

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
Copy link
Member

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
Copy link
Author

@jfversluis , it works!

Thank you!

salvadorjesus added a commit to salvadorjesus/Essentials that referenced this issue Apr 11, 2024
…targeting API 34 on Android 14 phones'

Fix for xamarin#2130 based on the fix dotnet/maui#19968 for Maui for the similar issue dotnet/maui#19949.

(cherry picked from commit 12a8465)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants