本文整理匯總了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);
}
}
}