Allows you to watch for wi-fi changes on an Android device.
val wifiMonitor = WifiMonitor.Builder()
.listener(wifiListener)
.wifiManager(wifiManager)
.permissionChecker(permissionChecker)
.build(context)
val callbackFlow = wifiMonitor.monitor()
// use the flow as you like
Sadly yes, to bootstrap the library you will need a valid context.
Add the JitPack repository to your build file
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Add the dependency
dependencies {
implementation 'com.github.Kuama-IT:android-kotlin-wifi-watcher:Tag'
}
only if you obtained the ACCESS_FINE_LOCATION
permission
When the wi-fi is connected.
With this state you also get the ssid of the wifi.
When the wi-fi is connected and your user didn't grant the ACCESS_FINE_LOCATION
permission.
When the phone is not connected to any Wi-Fi.
When the library could not recognize the Wi-Fi state.