Skip to content

fix(android): Only use the Handler overload of registerDefaultNetworkCallback on API 26+ - #6634

Merged
runningcode merged 2 commits into
mainfrom
fix/network-callback-handler-api26
Nov 17, 2026
Merged

runningcode merged 2 commits into
mainfrom
fix/network-callback-handler-api26

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

📜 Description

When an AndroidConnectionStatusProvider is built with a Handler, registerNetworkCallback calls ConnectivityManager.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 throws NoSuchMethodError. The broad catch swallows it, so no network callback gets registered and connection status updates stop.

This PR uses the Handler overload only on API 26+. On API 24–25 it falls back to registerDefaultNetworkCallback(callback), which is the path already taken when no Handler is 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 regular main → 9.x.x sync.

📝 Checklist

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

via no.

--

View Session [Sentry]

sentry-junior Bot and others added 2 commits November 17, 2026 10:04
…Callback on API 26+

Co-Authored-By: Nelson Osacky <nelson.osacky@sentry.io>
Co-Authored-By: Nelson Osacky <nelson.osacky@sentry.io>
@runningcode
runningcode marked this pull request as ready for review November 17, 2026 10:06
@runningcode
runningcode requested review from a team and adinauer as code owners November 17, 2026 10:06
@runningcode
runningcode requested review from 0xadam-brown and romtsn and removed request for a team November 17, 2026 10:06
@sentry

sentry Bot commented Nov 17, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
SDK Size io.sentry.tests.size 8.64.0 (1) release

⚙️ sentry-android Build Distribution Settings

@github-actions github-actions Bot added the risk: low PR risk score: low label Nov 17, 2026
@runningcode
runningcode enabled auto-merge (squash) November 17, 2026 10:07
@runningcode
runningcode merged commit c58f4a4 into main Nov 17, 2026
48 of 49 checks passed
@runningcode
runningcode deleted the fix/network-callback-handler-api26 branch November 17, 2026 10:12
sentry-junior Bot added a commit that referenced this pull request Nov 17, 2026
Resolve CHANGELOG.md conflict by keeping both Unreleased Fixes entries (#6542 and #6634).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: low PR risk score: low

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant