Tag Archives: isAvailable

How to check different Network status in Android?

By | May 5, 2012

This code snippet checks which of your networks are available in android. [java] package com.coderzheaven.pack; import android.app.Activity; import android.content.Context; import android.net.ConnectivityManager; import android.os.Bundle; import android.widget.Toast; public class CheckConnectionsDemo extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); checkAvailableConnection(); } void checkAvailableConnection() { ConnectivityManager connMgr = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); final android.net.NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); final android.net.NetworkInfo mobile =… Read More »

How to check internet connection is available in ANDROID or not?

By | July 7, 2011

Today we will see how to check whether there is any internet connection available to your phone in android.If any of the internet connection is available then the below function returns true otherwise false. [java] private boolean checkInternetConnection() { ConnectivityManager conMgr = (ConnectivityManager) getSystemService (Context.CONNECTIVITY_SERVICE); if (conMgr.getActiveNetworkInfo() != null && conMgr.getActiveNetworkInfo().isAvailable() && conMgr.getActiveNetworkInfo().isConnected()) { return true; } else… Read More »