正如 Google 文档所说,您需要实现以下代码,以便在 WIFI 扫描操作完成时收到通知:
val wifiScanReceiver = object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
val success = intent.getBooleanExtra(WifiManager.EXTRA_RESULTS_UPDATED, false)
if (success) {
scanSuccess()
} else {
scanFailure()
}
}
}
但是
WifiManager.EXTRA_RESULTS_UPDATED
需要api 23及以上,如何计算api中低于23的success
值?