Check Internet Connectivity in android

/* * @return boolean return true if the application can access the internet */ private boolean haveInternet(){ NetworkInfo info = ((ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE)).getActiveNetworkInfo(); if (info==null || !info.isConnected()) { return false; } if (info.isRoaming()) { // here is the roaming option you can change it if you want to disable internet while roaming, just return false return true; } return true; }
Checking the internet connection of an android app while using it.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.