本文整理汇总了Java中android.net.wifi.WifiManager.disableNetwork方法的典型用法代码示例。如果您正苦于以下问题:Java WifiManager.disableNetwork方法的具体用法?Java WifiManager.disableNetwork怎么用?Java WifiManager.disableNetwork使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.net.wifi.WifiManager
的用法示例。
在下文中一共展示了WifiManager.disableNetwork方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: onCreate
import android.net.wifi.WifiManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
setContentView(R.layout.activity_bind_device_error);
AndroidBug54971Workaround.assistActivity(findViewById(android.R.id.content));
int currentapiVersion = android.os.Build.VERSION.SDK_INT;
if (currentapiVersion >= 20) {
getWindow().setStatusBarColor(getResources().getColor(R.color.bar_color));
}
llBack = (LinearLayout) findViewById(R.id.ll_back);
// llBack.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// finish();
// }
// });
TextView btnSure = (TextView) findViewById(R.id.tvEditSure);
btnSure.setVisibility(View.INVISIBLE);
llBack.setVisibility(View.INVISIBLE);
TextView tvTitle = (TextView) findViewById(R.id.tvTitle);
tvTitle.setText(R.string.find_devices);
type = getIntent().getIntExtra("type", 0);
//断开网络重新连接
if (type == 1) {
WifiManager wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
String ssid = wifiManager.getConnectionInfo().getSSID();
if (ssid.contains("Photon-") && ssid.length() >= 11) {
wifiManager.disableNetwork(wifiManager.getConnectionInfo().getNetworkId());
//连接到最后一次的网络上
wifiManager.reconnect();
}
}
}