當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。