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 {
    /**
     * Enables or disables wifi.  Requires CHANGE_WIFI_STATE permission.
     * 
     * @param context A context with which to access wifi system service
     * @param enable True if wifi should be enabled, false if it should be disabled
     */
    public static void enableWifi(ContextWrapper context, boolean enable) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        wifiManager.setWifiEnabled(enable);
    }
}