本文整理汇总了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();
}
}
}
示例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;
}
示例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();
}
示例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;
}
示例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();
}
示例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));
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}