我有一个用于与wifi连接的代码:
override fun setupWifi(ssid: String, password: String) {
try {
val wifiConfig = WifiConfiguration()
wifiConfig.SSID = String.format("\"%s\"", ssid)
wifiConfig.preSharedKey = String.format("\"%s\"", password)
val wifiManager = getSystemService(Context.WIFI_SERVICE) as WifiManager
wifiManager.isWifiEnabled = true
val netId = wifiManager.addNetwork(wifiConfig)
wifiManager.disconnect()
wifiManager.enableNetwork(netId, true)
wifiManager.reconnect()
ReactiveNetwork
.observeNetworkConnectivity(applicationContext)
.subscribeOn(Schedulers.io())
.filter(ConnectivityPredicate.hasState(NetworkInfo.State.CONNECTED))
.filter(ConnectivityPredicate.hasType(ConnectivityManager.TYPE_WIFI))
.observeOn(AndroidSchedulers.mainThread())
.subscribeBy(onNext = { connectivity ->
if (connectivity.available())
presenter.showActivationScreen()
}, onError = {
presenter.showPasswordError()
logger.e("wificonfigactivity", "wifi connection failed", it)
}, onComplete = {
logger.d("wificonfigactivity", "wifi connection failed")
})
.addTo(startStopDisposables)
} catch (e: Exception) {
showError(getString(R.string.activation_wlan_error))
}
}
现在,我有一个问题-如何检查用户输入的密码是否错误?