Repository navigation
fix(android): Only use the Handler overload of registerDefaultNetworkCallback on API 26+ - #6634
Merged
Merged
Conversation
…Callback on API 26+ Co-Authored-By: Nelson Osacky <nelson.osacky@sentry.io>
runningcode
marked this pull request as ready for review
November 17, 2026 10:06
runningcode
requested review from
0xadam-brown and
romtsn
and removed request for
a team
November 17, 2026 10:06
📲 Install BuildsAndroid
|
runningcode
approved these changes
Nov 17, 2026
runningcode
enabled auto-merge (squash)
November 17, 2026 10:07
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
When an
AndroidConnectionStatusProvideris built with aHandler,registerNetworkCallbackcallsConnectivityManager.registerDefaultNetworkCallback(callback, handler). That overload was added in API 26, but the only guard in front of it is API 24 (N). On API 24–25 the call throwsNoSuchMethodError. The broadcatchswallows it, so no network callback gets registered and connection status updates stop.This PR uses the
Handleroverload only on API 26+. On API 24–25 it falls back toregisterDefaultNetworkCallback(callback), which is the path already taken when noHandleris passed, so callbacks run on the system's default connectivity thread.The default SDK setup passes no
Handler, so this only affects apps that build the provider with one.💡 Motivation and Context
The same code is on
9.x.x, and it reaches that branch through the regularmain→9.x.xsync.📝 Checklist
sendDefaultPIIis enabled.via no.
--
View Session [Sentry]