我以编程方式使用
与WiFi网络断开连接WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.disconnect();
DisconnectWifi discon = new DisconnectWifi();
registerReceiver(discon, new IntentFilter(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION));
public class DisconnectWifi extends BroadcastReceiver {
@Override
public void onReceive(Context c, Intent intent) {
WifiManager wifi = (WifiManager) c.getSystemService(Context.WIFI_SERVICE);
if(!intent.getParcelableExtra(WifiManager.EXTRA_NEW_STATE).toString().equals(SupplicantState.SCANNING))
wifi.disconnect();
}
}
但我无法再次重新连接到同一网络。我尝试使用以下方法重新连接:
WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
wifi.reconnect();
但无法连接。我现在如何重新连接到WiFi网络?
谢谢,
答案 0 :(得分:1)
因此完整,简化的解决方案看起来像这样:
static mapping = {
mstAttributeList {
column name: 'SITE'
column name: 'MACHINE_FK', sqlType: 'nvarchar2'
}
mstAttributeList joinTable: [name: 'MST_MACHINE_ATTRIBUTE', key: ['MACHINE_FK', 'SITE']]
}
static hasMany = [ mstAttributeList : com.gknsintermetals.mda.master.MstAttribute ]
希望它能帮助你!!