is Wifi Enabled - Android Phone

Android examples for Phone:wifi

Description

is Wifi Enabled

Demo Code


//package com.java2s;

import android.content.Context;

import android.net.ConnectivityManager;

import android.net.NetworkInfo.State;

import android.telephony.TelephonyManager;

public class Main {

    public static boolean isWifiEnabled(Context context) {
        ConnectivityManager mgrConn = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        TelephonyManager mgrTel = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        return ((mgrConn.getActiveNetworkInfo() != null && mgrConn
                .getActiveNetworkInfo().getState() == State.CONNECTED) || mgrTel
                .getNetworkType() == TelephonyManager.NETWORK_TYPE_UMTS);
    }/*from ww w. ja v a  2  s  .  co m*/
}

Related Tutorials