当前位置: 首页>>代码示例>>Java>>正文


Java WifiManager.removeNetwork方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:25,代码来源:WifiConfigManager.java

示例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();

}
 
开发者ID:ThanosFisherman,项目名称:WifiUtils,代码行数:25,代码来源:ConnectorUtils.java

示例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);
    }
}
 
开发者ID:xiong-it,项目名称:ZXingAndroidExt,代码行数:26,代码来源:WifiConfigManager.java

示例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;
        }
    }
}
 
开发者ID:hoanglm4,项目名称:RxAndroidTBP,代码行数:17,代码来源:NetworkUtil.java

示例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;
}
 
开发者ID:ThanosFisherman,项目名称:WifiUtils,代码行数:14,代码来源:ConnectorUtils.java

示例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);
        }
    }
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:15,代码来源:WiFiUtils.java


注:本文中的android.net.wifi.WifiManager.removeNetwork方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。