List of usage examples for android.net.wifi WifiManager removeNetwork
public boolean removeNetwork(int netId)
From source file:com.sentaroh.android.TaskAutomation.TaskExecutor.java
final static public boolean setWifiRemoveSsid(TaskManagerParms taskMgrParms, EnvironmentParms envParms, CommonUtilities util, TaskResponse taskResponse, ActionResponse ar) { WifiManager wm = (WifiManager) taskMgrParms.context.getSystemService(Context.WIFI_SERVICE); int nwid = wm.getConnectionInfo().getNetworkId(); if (envParms.isWifiConnected()) { if (!envParms.wifiSsid.equals(EnvironmentParms.WIFI_DIRECT_SSID)) { wm.removeNetwork(nwid); ar.action_resp = ActionResponse.ACTION_SUCCESS; ar.resp_msg_text = ""; return true; } else {/*w w w . j av a 2s. co m*/ ar.action_resp = ActionResponse.ACTION_WARNING; ar.resp_msg_text = "Can not removed, WiFi is connected to WiFi-Direct"; return false; } } ar.action_resp = ActionResponse.ACTION_WARNING; ar.resp_msg_text = "Wifi not connected"; return false; }
From source file:com.landenlabs.all_devtool.NetFragment.java
private void clean_networks() { StringBuilder sb = new StringBuilder(); final WifiManager wifiMgr = (WifiManager) getContext().getApplicationContext() .getSystemService(Context.WIFI_SERVICE); if (wifiMgr != null && wifiMgr.isWifiEnabled() && wifiMgr.getDhcpInfo() != null) { try {//from www. j a v a 2 s . c om List<WifiConfiguration> listWifiCfg = wifiMgr.getConfiguredNetworks(); for (WifiConfiguration wifiCfg : listWifiCfg) { if (wifiCfg.allowedKeyManagement.get(WifiConfiguration.KeyMgmt.NONE)) { // Remove network connections with no Password. if (wifiMgr.removeNetwork(wifiCfg.networkId)) { sb.append(wifiCfg.SSID); sb.append("\n"); } } } } catch (Exception ex) { } } if (sb.length() != 0) { Toast.makeText(this.getContext(), "Removed Networks: " + sb.toString(), Toast.LENGTH_LONG).show(); } }