Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import android.content.Context;
import android.content.ContextWrapper;

import android.net.wifi.WifiManager;

public class Main {
    /**
     * Determines if the device's wifi is currently enabled or not.
     * 
     * @param context A context with which to access wifi system service
     * @return True if wifi is enabled or enabling, false otherwise
     */
    public static boolean wifiIsEnabled(ContextWrapper context) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        int wifiState = wifiManager.getWifiState();
        return (wifiState == WifiManager.WIFI_STATE_ENABLED || wifiState == WifiManager.WIFI_STATE_ENABLING);
    }
}