Android Network State Check isOnline(Context context)

Here you can find the source of isOnline(Context context)

Description

is Online

Declaration

static boolean isOnline(Context context) 

Method Source Code

//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;

public class Main {
    static boolean isOnline(Context context) {
        try {//from   w  w w.  j a  v a  2 s  .  c  o  m
            ConnectivityManager cm = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            return cm.getActiveNetworkInfo().isConnected();
        } catch (Exception e) {
            return false;
        }

    }
}

Related

  1. isOnline(Context c)
  2. isOnline(Context context)
  3. isNetworkReady(Context context)
  4. isConMeNetwork(String ssid)
  5. isConnectNetWork(final Context context)
  6. isNetworkAvailable(Context context)
  7. isNetworkAvailable(Context context)
  8. isMobileOnline(Context context)
  9. isInternetReachable(Context context)