Example usage for android.content Context WIFI_SERVICE

List of usage examples for android.content Context WIFI_SERVICE

Introduction

In this page you can find the example usage for android.content Context WIFI_SERVICE.

Prototype

String WIFI_SERVICE

To view the source code for android.content Context WIFI_SERVICE.

Click Source Link

Document

Use with #getSystemService(String) to retrieve a android.net.wifi.WifiManager for handling management of Wi-Fi access.

Usage

From source file:Main.java

public static WifiManager getWifiManager(Context ctx) {
    return (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE);
}

From source file:Main.java

public static boolean isWIFIActivate(Context context) {
    return ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).isWifiEnabled();
}

From source file:Main.java

static String getMacAddress(Context context) {
    WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    String m_szWLANMAC = wm.getConnectionInfo().getMacAddress();
    return m_szWLANMAC;
}

From source file:Main.java

public static void changeWIFIStatus(Context context, boolean status) {
    ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).setWifiEnabled(status);
}

From source file:Main.java

public static WifiManager getWifiManager(final Context pContext) {
    return (WifiManager) pContext.getSystemService(Context.WIFI_SERVICE);
}

From source file:Main.java

public static boolean isEnabledWifi(Context context) {
    WifiManager wifiMan = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return null != wifiMan && wifiMan.getWifiState() == WifiManager.WIFI_STATE_ENABLED;
}

From source file:Main.java

public static boolean isWifiEnable(Context context) {
    WifiManager mgr = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (mgr == null)
        return false;
    int state = mgr.getWifiState();
    return state == WifiManager.WIFI_STATE_ENABLED || state == WifiManager.WIFI_STATE_ENABLING;
}

From source file:Main.java

public static int getWifiState(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    if (wifiManager != null) {
        return wifiManager.getWifiState();
    }/*from w ww.j av  a  2 s. c o  m*/
    return WifiManager.WIFI_STATE_DISABLED;
}

From source file:Main.java

public static boolean isOnWifi(Context context) {
    WifiManager lWifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return lWifiManager == null ? false
            : lWifiManager.isWifiEnabled() && lWifiManager.getConnectionInfo() != null
                    && lWifiManager.getConnectionInfo().getIpAddress() != 0;
}

From source file:Main.java

public static boolean isWifiEnabled(Context context) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    return wifiManager.isWifiEnabled();
}