Repository navigation
[network_info_plus] Use new Android APIs - #1151
Merged
vbuberen merged 7 commits intoOct 4, 2022
Merged
Conversation
vbuberen
commented
Oct 3, 2022
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) { | ||
| val linkAddresses = connectivityManager?.getLinkProperties(connectivityManager.activeNetwork)?.linkAddresses | ||
|
|
||
| val ipV4Address = linkAddresses?.firstOrNull { linkAddress -> |
Collaborator
Author
vbuberen
commented
Oct 3, 2022
|
|
||
| <uses-permission android:name="android.permission.INTERNET" /> | ||
| <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> |
Collaborator
Author
There was a problem hiding this comment.
Added it, so it is easy to open Settings of example app and grant permission without introducing any dependency to handle permission in this app.
miquelbeltran
approved these changes
Oct 4, 2022
Member
|
2.3.0 published |
|
I have Android 13 (Pixel 5). Just tried with Android 9 and SSID is OK. Example in plugin project also shows me SSID: null |
6 of 7 tasks
|
Why is wifi name still null |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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
While working on #1090 saw that plugin uses some deprecated APIs.
Namely, there were usages of:
I modified the code, so on devices with Android 12 (S) and newer plugin uses new recommended way of getting the same information. Now plugin relies on ConnectivityManager.getLinkProperties() and ConnectivityManager.getNetworkCapabilities() for such devices.
Both functions mention that they require
Manifest.permission.ACCESS_NETWORK_STATE, but during testing on emulators code worked fine for me even without this permission being added into AndroidManifest. Nevertheless, add info about this permission to docs and README, since don't trust emulator much.Additionally did a minor update to
exampleapp to show info in more pretty form:Before:

After:

Related Issues
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]).This will ensure a smooth and quick review process.
pubspec.yamlandCHANGELOG.md.///).flutter analyze) does not report any problems on my PR.Breaking Change
Does your PR require plugin users to manually update their apps to accommodate your change?