WAI
Status Update
Comments
di...@gmail.com <di...@gmail.com> #2
Sai
ku...@google.com <ku...@google.com>
ku...@google.com <ku...@google.com> #3
We have passed this to the development team and will update this case with more information as it becomes available.
ku...@google.com <ku...@google.com> #4
Response from engineering team:
==========================================
You can do this by using the ConnectivityManager.registerNetworkCallback().
==> Code Snippet:
final NetworkRequest request =
new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build();
final ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkCallback networkCallback = new NetworkCallback() {
...
@Override
void onAvailable(...) {
// Connected to wifi network with internet access.
}
@Override
void onLost(...) {
// Lost connection from a wifi network with internet access.
}
...
};
connectivityManager.registerNetworkCallback(request, networkCallback);
==========================================
You can do this by using the ConnectivityManager.registerNetworkCallback().
==> Code Snippet:
final NetworkRequest request =
new NetworkRequest.Builder()
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
.build();
final ConnectivityManager connectivityManager = (ConnectivityManager)
context.getSystemService(Context.CONNECTIVITY_SERVICE);
final NetworkCallback networkCallback = new NetworkCallback() {
...
@Override
void onAvailable(...) {
// Connected to wifi network with internet access.
}
@Override
void onLost(...) {
// Lost connection from a wifi network with internet access.
}
...
};
connectivityManager.registerNetworkCallback(request, networkCallback);
ad...@gmail.com <ad...@gmail.com> #5
in this answer it only respond when internet is connected suppose my internet is off and i on my app it dont show anything or toast if i set it in method and when i on the internet the app dont show response about the connectivity until i restart my app kindly guide me what is the issue about it
Description
It would be useful that the Android API could provide this info.
I know I can get the info by pinging a server such as