本文整理匯總了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();
}
}
}