List of usage examples for android.content Context WIFI_SERVICE
String WIFI_SERVICE
To view the source code for android.content Context WIFI_SERVICE.
Click Source Link
From source file:Main.java
public static List<WifiConfiguration> getWifiConfigrations(Context context) { WifiManager mainWifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); List<WifiConfiguration> list = mainWifi.getConfiguredNetworks(); return list;/* ww w .j ava 2 s . co m*/ }
From source file:Main.java
public static void setWifiOn(Context context) { WifiManager manager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); manager.setWifiEnabled(true); }
From source file:Main.java
public static List<ScanResult> getWifiScanResults(Context context) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); return wifiManager.startScan() ? wifiManager.getScanResults() : null; }
From source file:Main.java
public static int addNetwork(Context context, WifiConfiguration wifiConfig) { setWifiEnable(context, true);//from w w w . jav a 2 s . c o m WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int netId = wifi.addNetwork(wifiConfig); wifi.saveConfiguration(); return netId; }
From source file:Main.java
public static void connectionWifi(Context context, WifiConfiguration wifiConfig, int ntind, boolean wantConnection) { WifiManager wifi = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); // wifi.saveConfiguration(); wifi.updateNetwork(wifiConfig);// w ww. j av a 2s . c o m wifi.enableNetwork(ntind, wantConnection); }
From source file:Main.java
@SuppressWarnings("MissingPermission") public static String getWifiMacAddr(Context ctx) { String macAddr = ""; try {/* w w w.j a v a 2 s .c om*/ WifiManager wifi = (WifiManager) ctx.getSystemService(Context.WIFI_SERVICE); macAddr = wifi.getConnectionInfo().getMacAddress(); if (macAddr == null) { macAddr = ""; } } catch (Exception e) { e.printStackTrace(); } return macAddr; }
From source file:Main.java
/** * Check whether wifi is enabled/* w w w. j ava 2 s. c o m*/ * * @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 void setWifiEnabled(Context context, boolean enabled) { ((WifiManager) context.getSystemService(Context.WIFI_SERVICE)).setWifiEnabled(enabled); }
From source file:Main.java
public static ScanResult getScanResultsByBSSID(Context context, String bssid) { WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); ScanResult scanResult = null;/* w w w . j av a 2 s .c o m*/ boolean f = wifiManager.startScan(); if (!f) { getScanResultsByBSSID(context, bssid); } List<ScanResult> list = wifiManager.getScanResults(); if (list != null) { for (int i = 0; i < list.size(); i++) { scanResult = list.get(i); if (scanResult.BSSID.equals(bssid)) { break; } } } return scanResult; }
From source file:Main.java
public static WifiManager.WifiLock createWifiLock(Context context, String tag) { WifiManager wm = (WifiManager) context.getSystemService(Context.WIFI_SERVICE); int lockType = WifiManager.WIFI_MODE_FULL; // Use WIFI_MODE_FULL_HIGH_PERF if API level 12 or higher. if (Build.VERSION.SDK_INT >= 12) { lockType = 3; // WifiManager.WIFI_MODE_FULL_HIGH_PERF }// ww w . j a va2 s. c o m return wm.createWifiLock(lockType, tag); }