Skip to content

Fix connectivity broadcast receiver never triggered on android 14.0/34+ #19968

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

pierre-galaup
Copy link
Contributor

@pierre-galaup pierre-galaup commented Jan 18, 2024

Description of Change

For connectivity, we need to set the broadcastreceiver parameter to EXPORTED.

As you can see, the EXPORTED parameter is required for broadcasts sent from the system: https://developer.android.com/develop/background-work/background-tasks/broadcasts#context-registered-receivers

Without the parameter, the ConnectivityChanged event is never triggered.

I've tested the fix on a Google Pixel 8 Pro in ANDROID 14 and it works.

Issues Fixed

Fix issue #19949

@pierre-galaup pierre-galaup requested a review from a team as a code owner January 18, 2024 10:40
@ghost ghost added the community ✨ Community Contribution label Jan 18, 2024
@ghost
Copy link

ghost commented Jan 18, 2024

Hey there @pierre-galaup! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed.

@jfversluis
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@samhouts samhouts added the area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info label Jan 25, 2024
@gabsamples6
Copy link

Hi - will this be soon merged so that we can test on nightly build? many thanks

@PureWeen PureWeen requested review from Redth and mattleibow and removed request for StephaneDelcroix and tj-devel709 February 5, 2024 16:25
@Redth
Copy link
Member

Redth commented Feb 5, 2024

Interesting - I didn't have an android 14 device to test on, though I think @mattleibow did test and it seemed that export didn't make a difference in testing? We were trying to be conservative in exporting this, but it would make sense that it is needed - the docs aren't super clear unfortunately from Google.

@Redth
Copy link
Member

Redth commented Feb 5, 2024

/rebase

…er where the ConnectivityChanged event was never triggered.
@github-actions github-actions bot force-pushed the fix-android14-connectivity-broadcastreceiver branch from c97a7c6 to 1d8ecb0 Compare February 5, 2024 21:08
@Redth
Copy link
Member

Redth commented Feb 12, 2024

Tested this on a physical device with Android 14.0 and can confirm without exporting the receiver, the updates are never received.

This change does fix this case for me in testing as well.

Thanks for the PR!

@Redth
Copy link
Member

Redth commented Feb 12, 2024

/azp run

Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@rmarinho rmarinho merged commit d9e1804 into dotnet:main Feb 13, 2024
salvadorjesus added a commit to salvadorjesus/Essentials that referenced this pull request 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.
@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2024
salvadorjesus added a commit to salvadorjesus/Essentials that referenced this pull request 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
area-essentials Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info community ✨ Community Contribution fixed-in-8.0.10 fixed-in-9.0.0-preview.2.10247 fixed-in-9.0.0-preview.2.10293 platform/android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding a Connectivity.ConnectivityChanged handler does not work on Android 14
6 participants