但是当我将我的应用程序与 WiFi 连接时,它仍然显示没有连接 WiFi,所以我必须关闭应用程序并在连接 WiFi 的情况下再次打开它。
if (wifimanager.setWifiEnabled(true)) {
punchin.setOnClickListener {
if ((conMgr.activeNetworkInfo != null) && (wifi.isAvailable == true && wifi.isConnected == true)) {
Log.v("MAc", "mac=" + wMAC + "\n" + wbssid + "\n" + wssid)
if ((wbssid == "") && (wssid.equals(""))
&& conMgr.activeNetworkInfo != null && conMgr.activeNetworkInfo.isAvailable
&& conMgr.activeNetworkInfo.isConnected) {
textView.text = "Connected to correct Wifi"
punchout.visibility = View.VISIBLE
} else if (wbssid!="") {
Toast.makeText(applicationContext, "Connect To Correct Wifi", Toast.LENGTH_LONG).show()
}
} else {
Toast.makeText(this, "No Wifi Connection", Toast.LENGTH_LONG).show()
}
}
}