List of usage examples for android.net.wifi WifiManager isWifiEnabled
public boolean isWifiEnabled()
From source file:Main.java
public static String getDevicesIP(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); }/*w ww. j av a 2 s . c o m*/ WifiInfo wifiInfo = wifiManager.getConnectionInfo(); int ipAddress = wifiInfo.getIpAddress(); String ip = (ipAddress & 0xFF) + "." + ((ipAddress >> 8) & 0xFF) + "." + ((ipAddress >> 16) & 0xFF) + "." + (ipAddress >> 24 & 0xFF); if (ip == null || ip.equals("0.0.0.0")) { } return ip; }
From source file:Main.java
public static void tryEnablingWifi(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); }// w w w. ja v a2 s . co m }
From source file:Main.java
public static String getWiFiIP(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); }//from w w w . j ava2 s .c o m WifiInfo wifiinfo = wifiManager.getConnectionInfo(); String ip = intToIp(wifiinfo.getIpAddress()); return ip; }
From source file:Main.java
/** * Check whether wifi is enabled//from ww w. java 2 s . c om * * @param activity context */ public static boolean isWifiEnabled(Context c) { WifiManager wifiManager = (WifiManager) c.getSystemService(Context.WIFI_SERVICE); return (wifiManager.isWifiEnabled()); }
From source file:Main.java
public static String getWIFIIP(Context context) { WifiManager wifimanage = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (!wifimanage.isWifiEnabled()) { wifimanage.setWifiEnabled(true); }/*ww w . ja v a 2s . co m*/ WifiInfo wifiinfo = wifimanage.getConnectionInfo(); String ip = intToIp(wifiinfo.getIpAddress()); return ip; }
From source file:Main.java
public static boolean isWiFiEnabled(final Context context) { final WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return wifiManager.isWifiEnabled(); }
From source file:Main.java
private static void setWifi(int wifiVal) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); if (wifiVal == 0 && !wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(true); } else if (wifiVal == 1 && wifiManager.isWifiEnabled()) { wifiManager.setWifiEnabled(false); }//from w w w. j a v a 2s. co m }
From source file:Main.java
public static String getWifiIp(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); boolean enable = wifiManager.isWifiEnabled(); if (!enable) { return null; }/*ww w. j a v a2 s . c o m*/ WifiInfo wifiinfo = wifiManager.getConnectionInfo(); return intToIp(wifiinfo.getIpAddress()); }
From source file:Main.java
public static String getGateWayAddress(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); boolean enable = wifiManager.isWifiEnabled(); if (!enable) { return null; }//from w ww . ja va 2 s . c o m DhcpInfo info = wifiManager.getDhcpInfo(); return intToIp(info.gateway); }
From source file:Main.java
public static boolean getWifiEnableState(Context context, boolean sw) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); boolean enabled = wifiManager.isWifiEnabled(); return enabled; }