當前位置: 首頁>>代碼示例>>Java>>正文


Java WifiManager.getConfiguredNetworks方法代碼示例

本文整理匯總了Java中android.net.wifi.WifiManager.getConfiguredNetworks方法的典型用法代碼示例。如果您正苦於以下問題:Java WifiManager.getConfiguredNetworks方法的具體用法?Java WifiManager.getConfiguredNetworks怎麽用?Java WifiManager.getConfiguredNetworks使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.net.wifi.WifiManager的用法示例。


在下文中一共展示了WifiManager.getConfiguredNetworks方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: connectToKnownWifi

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public static void connectToKnownWifi(Context context, String ssid) {
    WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    List<WifiConfiguration> list = wifiManager.getConfiguredNetworks();
    for (WifiConfiguration i : list) {
        if (i.SSID != null && i.SSID.equals("\"" + ssid + "\"")) {
            wifiManager.disconnect();
            wifiManager.enableNetwork(i.networkId, true);
            wifiManager.reconnect();
        }
    }
}
 
開發者ID:hoanglm4,項目名稱:RxAndroidTBP,代碼行數:12,代碼來源:NetworkUtil.java

示例2: getWifiConfiguration

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Nullable
static WifiConfiguration getWifiConfiguration(@NonNull final WifiManager wifiMgr, @NonNull final ScanResult scanResult) {
    if (scanResult.BSSID == null || scanResult.SSID == null || scanResult.SSID.isEmpty() || scanResult.BSSID.isEmpty())
        return null;
    final String ssid = convertToQuotedString(scanResult.SSID);
    final String bssid = scanResult.BSSID;
    final String security = getSecurity(scanResult);

    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    if (configurations == null)
        return null;

    for (final WifiConfiguration config : configurations) {
        if (bssid.equals(config.BSSID) || ssid.equals(config.SSID)) {
            final String configSecurity = getSecurity(config);
            if (Objects.equals(security, configSecurity))
                return config;
        }
    }
    return null;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:22,代碼來源:ConfigSecurities.java

示例3: 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

示例4: disableAllButOne

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static boolean disableAllButOne(@NonNull final WifiManager wifiManager, @Nullable final WifiConfiguration config) {
    @Nullable final List<WifiConfiguration> configurations = wifiManager.getConfiguredNetworks();
    if (configurations == null || config == null || configurations.isEmpty())
        return false;
    boolean result = false;

    for (WifiConfiguration wifiConfig : configurations)
        if (wifiConfig.networkId == config.networkId)
            result = wifiManager.enableNetwork(wifiConfig.networkId, true);
        else
            wifiManager.disableNetwork(wifiConfig.networkId);
    wifiLog("disableAllButOne " + result);
    return result;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:15,代碼來源:ConnectorUtils.java

示例5: writeToEntropyPool

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
@Override
protected void writeToEntropyPool(DataOutputStream out) throws IOException {
	super.writeToEntropyPool(out);
	out.writeInt(android.os.Process.myPid());
	out.writeInt(android.os.Process.myTid());
	out.writeInt(android.os.Process.myUid());
	if (Build.FINGERPRINT != null) out.writeUTF(Build.FINGERPRINT);
	if (Build.SERIAL != null) out.writeUTF(Build.SERIAL);
	ContentResolver contentResolver = appContext.getContentResolver();
	String id = Settings.Secure.getString(contentResolver, ANDROID_ID);
	if (id != null) out.writeUTF(id);
	Parcel parcel = Parcel.obtain();
	WifiManager wm =
			(WifiManager) appContext.getSystemService(WIFI_SERVICE);
	List<WifiConfiguration> configs = wm.getConfiguredNetworks();
	if (configs != null) {
		for (WifiConfiguration config : configs)
			parcel.writeParcelable(config, 0);
	}
	BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
	if (bt != null) {
		for (BluetoothDevice device : bt.getBondedDevices())
			parcel.writeParcelable(device, 0);
	}
	out.write(parcel.marshall());
	parcel.recycle();
}
 
開發者ID:rafjordao,項目名稱:Nird2,代碼行數:28,代碼來源:AndroidSecureRandomProvider.java

示例6: shouldBypassWiFiSetup

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
/**
 * Helper method to decide whether to bypass conference WiFi setup.  Return true if
 * WiFi AP is already configured (WiFi adapter enabled) or WiFi configuration is complete
 * as per shared preference.
 */
public static boolean shouldBypassWiFiSetup(final Context context) {
    final WifiManager wifiManager =
            (WifiManager) context.getSystemService(Context.WIFI_SERVICE);

    // Is WiFi on?
    if (wifiManager.isWifiEnabled()) {
        // Check for existing APs.
        final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();
        final String conferenceSSID = getConferenceWifiConfig().SSID;
        for(WifiConfiguration config : configs) {
            if (conferenceSSID.equalsIgnoreCase(config.SSID)) return true;
        }
    }

    return WIFI_CONFIG_DONE.equals(getWiFiConfigStatus(context));
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:22,代碼來源:WiFiUtils.java

示例7: 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

示例8: getMaxPriority

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static int getMaxPriority(@NonNull final WifiManager wifiManager) {
    final List<WifiConfiguration> configurations = wifiManager.getConfiguredNetworks();
    int pri = 0;
    for (final WifiConfiguration config : configurations) {
        if (config.priority > pri) {
            pri = config.priority;
        }
    }
    return pri;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:11,代碼來源:ConnectorUtils.java

示例9: shiftPriorityAndSave

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static int shiftPriorityAndSave(@NonNull final WifiManager wifiMgr) {
    final List<WifiConfiguration> configurations = wifiMgr.getConfiguredNetworks();
    sortByPriority(configurations);
    final int size = configurations.size();
    for (int i = 0; i < size; i++) {
        final WifiConfiguration config = configurations.get(i);
        config.priority = i;
        wifiMgr.updateNetwork(config);
    }
    wifiMgr.saveConfiguration();
    return size;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:13,代碼來源:ConnectorUtils.java

示例10: reEnableNetworkIfPossible

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public static boolean reEnableNetworkIfPossible(@NonNull final WifiManager wifiManager, @Nullable final ScanResult scanResult) {
    @Nullable final List<WifiConfiguration> configurations = wifiManager.getConfiguredNetworks();
    if (configurations == null || scanResult == null || configurations.isEmpty())
        return false;
    boolean result = false;
    for (WifiConfiguration wifiConfig : configurations)
        if (Objects.equals(scanResult.BSSID, wifiConfig.BSSID) && Objects.equals(scanResult.SSID, trimQuotes(wifiConfig.SSID))) {
            result = wifiManager.enableNetwork(wifiConfig.networkId, true);
            break;
        }
    wifiLog("reEnableNetworkIfPossible " + result);
    return result;
}
 
開發者ID:ThanosFisherman,項目名稱:WifiUtils,代碼行數:14,代碼來源:ConnectorUtils.java

示例11: findNetworkInExistingConfig

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) {
  Iterable<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
  for (WifiConfiguration existingConfig : existingConfigs) {
    if (existingConfig.SSID.equals(ssid)) {
      return existingConfig.networkId;
    }
  }
  return null;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:10,代碼來源:WifiConfigManager.java

示例12: findNetworkInExistingConfig

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) {
  Iterable<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
  if (existingConfigs != null) {
    for (WifiConfiguration existingConfig : existingConfigs) {
      String existingSSID = existingConfig.SSID;
      if (existingSSID != null && existingSSID.equals(ssid)) {
        return existingConfig.networkId;
      }
    }
  }
  return null;
}
 
開發者ID:amap-demo,項目名稱:weex-3d-map,代碼行數:13,代碼來源:WifiConfigManager.java

示例13: findNetworkInExistingConfig

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
private static Integer findNetworkInExistingConfig(WifiManager wifiManager, String ssid) {
    Iterable<WifiConfiguration> existingConfigs = wifiManager.getConfiguredNetworks();
    if (existingConfigs != null) {
        for (WifiConfiguration existingConfig : existingConfigs) {
            String existingSSID = existingConfig.SSID;
            if (existingSSID != null && existingSSID.equals(ssid)) {
                return existingConfig.networkId;
            }
        }
    }
    return null;
}
 
開發者ID:xiong-it,項目名稱:ZXingAndroidExt,代碼行數:13,代碼來源:WifiConfigManager.java

示例14: 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

示例15: isWiFiApConfigured

import android.net.wifi.WifiManager; //導入方法依賴的package包/類
public static boolean isWiFiApConfigured(final Context context) {
    final WifiManager wifiManager =
            (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
    final List<WifiConfiguration> configs = wifiManager.getConfiguredNetworks();

    if (configs == null) return false;

    // Check for existing APs.
    final String conferenceSSID = getConferenceWifiConfig().SSID;
    for(WifiConfiguration config : configs) {
        if (conferenceSSID.equalsIgnoreCase(config.SSID)) return true;
    }
    return false;
}
 
開發者ID:dreaminglion,項目名稱:iosched-reader,代碼行數:15,代碼來源:WiFiUtils.java


注:本文中的android.net.wifi.WifiManager.getConfiguredNetworks方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。