Q: check internet connections on tab click android? I want check the internet connections on tabbar click in the device and if my device is connected to wifi or mobile network then it should call the api further otherwise should show one dialog that please check your internet connections and the application should stay on the same page. Please help any help will be appreciated.

A: private boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager 
          = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null;
}

Here is the sample code to check internet connectivity in android. 
You may also need to add user permission 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

if you want to check which connection is established use this code snippet 
private boolean networkConnection() {
    boolean wifiConnection = false;
    boolean mobileConnection = false;

    ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo[] netInfo = cm.getAllNetworkInfo();
    for (NetworkInfo ni : netInfo) {
        if (ni.getTypeName().equalsIgnoreCase("WIFI"))
            if (ni.isConnected())
                wifiConnection = true;
        if (ni.getTypeName().equalsIgnoreCase("MOBILE"))
            if (ni.isConnected())
                mobileConnection = true;
    }
    return wifiConnection || mobileConnection ;
}

