本文整理汇总了Java中android.net.wifi.WifiManager.removeNetwork方法的典型用法代码示例。如果您正苦于以下问题:Java WifiManager.removeNetwork方法的具体用法?Java WifiManager.removeNetwork怎么用?Java WifiManager.removeNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.wifi.WifiManager
的用法示例。
在下文中一共展示了WifiManager.removeNetwork方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateNetwork
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
/**
* Update the network: either create a new network or modify an existing network
* @param config the new network configuration
*/
private static void updateNetwork(WifiManager wifiManager, WifiConfiguration config) {
Integer foundNetworkID = findNetworkInExistingConfig(wifiManager, config.SSID);
if (foundNetworkID != null) {
Log.i(TAG, "Removing old configuration for network " + config.SSID);
wifiManager.removeNetwork(foundNetworkID);
wifiManager.saveConfiguration();
}
int networkId = wifiManager.addNetwork(config);
if (networkId >= 0) {
// Try to disable the current network and start a new one.
if (wifiManager.enableNetwork(networkId, true)) {
Log.i(TAG, "Associating to network " + config.SSID);
wifiManager.saveConfiguration();
} else {
Log.w(TAG, "Failed to enable network " + config.SSID);
}
} else {
Log.w(TAG, "Unable to add network " + config.SSID);
}
}
示例2: checkForExcessOpenNetworkAndSave
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
@SuppressWarnings("UnusedReturnValue")
private static boolean checkForExcessOpenNetworkAndSave(@NonNull final ContentResolver resolver, @NonNull final WifiManager wifiMgr) {
final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
sortByPriority(configurations);
boolean modified = false;
int tempCount = 0;
final int numOpenNetworksKept = Build.VERSION.SDK_INT >= 17
? Settings.Secure.getInt(resolver, Settings.Global.WIFI_NUM_OPEN_NETWORKS_KEPT, 10)
: Settings.Secure.getInt(resolver, Settings.Secure.WIFI_NUM_OPEN_NETWORKS_KEPT, 10);
for (int i = configurations.size() - 1; i >= 0; i--) {
final WifiConfiguration config = configurations.get(i);
if (Objects.equals(ConfigSecurities.SECURITY_NONE, ConfigSecurities.getSecurity(config))) {
tempCount++;
if (tempCount >= numOpenNetworksKept) {
modified = true;
wifiMgr.removeNetwork(config.networkId);
}
}
}
return !modified || wifiMgr.saveConfiguration();
}
示例3: updateNetwork
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
/**
* Update the network: either create a new network or modify an existing network
*
* @param config the new network configuration
*/
private static void updateNetwork(WifiManager wifiManager, WifiConfiguration config) {
Integer foundNetworkID = findNetworkInExistingConfig(wifiManager, config.SSID);
if (foundNetworkID != null) {
Log.i(TAG, "Removing old configuration for network " + config.SSID);
wifiManager.removeNetwork(foundNetworkID);
wifiManager.saveConfiguration();
}
int networkId = wifiManager.addNetwork(config);
if (networkId >= 0) {
// Try to disable the current network and start a new one.
if (wifiManager.enableNetwork(networkId, true)) {
Log.i(TAG, "Associating to network " + config.SSID);
wifiManager.saveConfiguration();
} else {
Log.w(TAG, "Failed to enable network " + config.SSID);
}
} else {
Log.w(TAG, "Unable to add network " + config.SSID);
}
}
示例4: removeSSIDFromConfiguredNetwork
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
public static void removeSSIDFromConfiguredNetwork(Context context, String ssid) {
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
if (!wifiManager.isWifiEnabled())
wifiManager.setWifiEnabled(true);
List<WifiConfiguration> configuredWifiList = wifiManager.getConfiguredNetworks();
for (int x = 0; x < configuredWifiList.size(); x++) {
WifiConfiguration i = configuredWifiList.get(x);
if (i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
Log.w(TAG, "Removing network: " + i.SSID);
wifiManager.removeNetwork(i.networkId);
return;
}
}
}
示例5: cleanPreviousConfiguration
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
static boolean cleanPreviousConfiguration(@NonNull final WifiManager wifiManager, @NonNull final ScanResult scanResult) {
//On Android 6.0 (API level 23) and above if my app did not create the configuration in the first place, it can not remove it either.
final WifiConfiguration config = ConfigSecurities.getWifiConfiguration(wifiManager, scanResult);
wifiLog("Attempting to remove previous network config...");
if (config == null)
return true;
if (wifiManager.removeNetwork(config.networkId)) {
wifiManager.saveConfiguration();
return true;
}
return false;
}
示例6: uninstallConferenceWiFi
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
public static void uninstallConferenceWiFi(final Context context) {
// Create conferenceConfig
WifiConfiguration conferenceConfig = getConferenceWifiConfig();
WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
List<WifiConfiguration> configuredNetworks = wifiManager.getConfiguredNetworks();
for (WifiConfiguration wifiConfig: configuredNetworks) {
if (wifiConfig.SSID.equals(conferenceConfig.SSID)) {
LOGW(TAG, "Removing network: " + wifiConfig.networkId);
wifiManager.removeNetwork(wifiConfig.networkId);
}
}
}