当前位置: 首页>>代码示例>>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;未经允许,请勿转载。