Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.telephony.TelephonyManager;

public class Main {

    public static boolean isWiFiEnabled(Context context) {
        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        return ((cm != null && cm.getActiveNetworkInfo() != null
                && cm.getActiveNetworkInfo().getState() == NetworkInfo.State.CONNECTED)
                || tm != null && tm.getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
    }
}