Comments (3)
In Android OS, differentiating between NET_CAPABILITY_INTERNET
and NET_CAPABILITY_VALIDATED
is designed to give developers more granular control over network connections. : link
NET_CAPABILITY_INTERNET
is used to check if the current network is capable of connecting to the internet.NET_CAPABILITY_VALIDATED
is used before actual data exchange through the network to ensure that data can be successfully sent and received.
It appears that the differentiation between each status value, as currently implemented, is intended for usage according to their respective purposes.
If you have a different opinion or further insights, please feel free to leave a comment!
from nowinandroid.
Then how can we check if we are connected to WIFI but has internet connection or not ?? @yongsuk44
from nowinandroid.
@loke101 If you're asking about how to check if Wi-Fi is connected but not actually connected to the internet, I think I would handle it like this:
NetworkRequest.Builder()
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.build()
// ...
val networkCapabilities = getNetworkCapabilities(activeNetwork)
val hasActiveInternetConnection =
networkCapabilities?.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
&& networkCapabilities?.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)
By doing this, you should be able to determine cases where Wi-Fi is connected but there is no internet connection.
from nowinandroid.
Related Issues (20)
- [Testing FR] [feature:bookmarks] Add screenshot tests
- [Testing FR] [feature:bookmarks] Improve coverage of viewmodel
- [Testing FR] [feature:interests] Add screenshot tests
- [Testing FR] [feature:search] Add screenshot tests
- [Testing FR] [feature:settings] Add screenshot tests
- [Testing FR] [feature:settings] Improve ViewModel coverage
- [Testing FR] [feature:topic] Add screenshot tests
- [Testing FR] [sync:work] Improve test coverage of module
- [Testing FR] [feature:interests] Add large screen tests for 2-pane support
- [Bug]: why WithPartialCompilationAndDisabledBaselineProfile is the best result in StartupBenchmark HOT 2
- [Testing FR] [core:database] Room migration tests
- [FR]: Minimize Unnecessary Recompositions HOT 1
- [Bug]: enableEdgeToEdge() doesn't change the navigation bar color when the app is in the dark mode and the system is not in Android 14 HOT 1
- [CI] Code coverage report not shown when PR is generated from fork
- [Bug]: Current project is not applied ```android_studio``` style ktlint
- [Bug]: Bottom Bar Item is not highlighted in search
- Rename `Result` to `TaskState`
- [Bug]: App crash while scrolling the Interest category list HOT 1
- Navigation from Search to Interests HOT 1
- Wrong Search History State HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nowinandroid.