Android Network State Check isOnline(Activity activity)

Here you can find the source of isOnline(Activity activity)

Description

is Online

Declaration

public static boolean isOnline(Activity activity) 

Method Source Code

//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

public class Main {
    public static boolean isOnline(Activity activity) {
        ConnectivityManager cm = (ConnectivityManager) activity
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo netInfo = cm.getActiveNetworkInfo();
        if (netInfo != null && netInfo.isConnectedOrConnecting()) {
            return true;
        }//from   w w  w .  j  a  v a 2 s. c o m
        return false;
    }
}

Related

  1. IsInternetReachable()
  2. setMobileDataEnabled(Activity a, Context context, boolean enabled)
  3. isNetworkAvailable(Activity mainActivity)
  4. isDeviceOnline(Activity activity)
  5. isConnected(final Activity act)
  6. CheckInternet(Activity a)
  7. checkInternetConnection(Context context)