How to check internet access on Android? InetAddress never times out

If the device is in airplane mode (or presumably in other situations where there’s no available network), cm.getActiveNetworkInfo() will be null, so you need to add a null check. Modified (Eddie’s solution) below: public boolean isOnline() { ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo netInfo = cm.getActiveNetworkInfo(); return netInfo != null && netInfo.isConnectedOrConnecting(); } Also add … Read more

Download a file with Android, and showing the progress in a ProgressDialog

There are many ways to download files. Following I will post most common ways; it is up to you to decide which method is better for your app. Use AsyncTask and show the download progress in a dialog ============================================================= This method will allow you to execute some background processes and update the UI at the … Read more

tech