Skip to content

fix: replace deprecated NSD resolve APIs for API 34+#73

Merged
chrisuthe merged 1 commit intomainfrom
fix/nsd-deprecation-warnings
Mar 8, 2026
Merged

fix: replace deprecated NSD resolve APIs for API 34+#73
chrisuthe merged 1 commit intomainfrom
fix/nsd-deprecation-warnings

Conversation

@chrisuthe
Copy link
Copy Markdown
Owner

Summary

  • On API 34+ (Android 14), NsdManager.resolveService() and NsdServiceInfo.host are deprecated. This PR adds version-checked code paths that use the modern registerServiceInfoCallback and hostAddresses APIs on API 34+, while preserving the legacy path (with @Suppress("DEPRECATION")) for older devices.
  • Extracts the shared TXT-record parsing into handleResolvedService() to avoid duplication between the two code paths.

Test plan

  • Verify mDNS discovery and service resolution works on an API 34+ device/emulator
  • Verify mDNS discovery still works on a pre-API 34 device/emulator
  • Confirm no deprecation warnings from NsdDiscoveryManager.kt in build output

@chrisuthe chrisuthe merged commit 0a6d3ae into main Mar 8, 2026
@chrisuthe chrisuthe deleted the fix/nsd-deprecation-warnings branch March 8, 2026 02:48
…host

On API 34+ (Android 14), use registerServiceInfoCallback/hostAddresses
instead of the deprecated resolveService/host APIs. The legacy code path
is preserved behind @Suppress("DEPRECATION") for older devices.

The shared TXT-record parsing logic is extracted into handleResolvedService
to avoid duplication between the two code paths.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant