-
Notifications
You must be signed in to change notification settings - Fork 44
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
fix(network): modernize simplenetworkdetector with updated android apis #736
base: main
Are you sure you want to change the base?
fix(network): modernize simplenetworkdetector with updated android apis #736
Conversation
// Determine network type based on transport capabilities | ||
if (capabilities.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR)) { | ||
return CurrentNetwork.builder(NetworkState.TRANSPORT_CELLULAR) | ||
.subType("") // Additional details can be added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not possible to do activeNetwork.getSubtypeName()
like the older APIs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the question!
Unfortunately, getSubtypeName() is not available in the newer APIs like NetworkCapabilities. The newer APIs focus on transport-level details (e.g., cellular, WiFi) rather than providing specific subtype information like "LTE" or "HSPA."
Thank you for your review and feedback! 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
left a question otherwise LGTM
Related issue
This pull request resolves issue #735.
Summary of changes
This PR updates the
SimpleNetworkDetector
class to replace deprecated Android APIs with their modern counterparts while ensuring backward compatibility:getActiveNetworkInfo()
withgetActiveNetwork()
andgetNetworkCapabilities()
.NetworkCapabilities.TRANSPORT_*
constants to determine network type.getActiveNetworkInfo()
andTYPE_*
constants to support older devices.Additional improvements include:
null
checks to handle cases where modern APIs might returnnull
.Why these changes are important
Acknowledgment
Thank you for providing this opportunity to contribute to the project. I have done my best to follow the contribution guidelines and ensure the changes adhere to project standards.
If there are any further improvements or adjustments required, please let me know. I will be more than happy to address any feedback promptly.
Thank you for your time and consideration!