Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import android.net.NetworkInfo.State;

import android.content.Context;

import android.net.ConnectivityManager;

public class Main {
    public static boolean checkWifyNetworkInfo(Context context) {
        try {
            ConnectivityManager conMan = (ConnectivityManager) context
                    .getSystemService(Context.CONNECTIVITY_SERVICE);
            //wifi
            State wifi = conMan.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState();
            return (wifi == State.CONNECTED || wifi == State.CONNECTING);
        } catch (Exception e) {
            return true;
        }
    }
}