Can android differentiate between a lost internet connection and no
internet connect?
When I press a button on my app to open an image it shows a progress bar
of the image being downloaded and then it opens. If there is no wifi
connection it displays an error message saying "No wifi". I have used the
code below to check for a wifi connection:
ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork.isConnectedOrConnecting();
boolean isWiFi = activeNetwork.getType() ==
ConnectivityManager.TYPE_WIFI;
I want to implement an error message that is displayed when the connection
is lost. So if you click on the image and while its downloading you turn
off the wifi then it displays a message saying "wifi disconnected".
Is this possible? Whether a connection is lost or there is no wifi all you
are doing is checking if there is a connection available which is the same
thing
No comments:
Post a Comment