I'm using Network Connectivity Manager,
In this lambda function when "it" value is false the TOAST will show, BUT after once the Wi-Fi is turned on and the value changes to true it automatically navigates to the composable
it shouldn't navigate that way!
onClick = {
manager.observe(lifecycleOwner.value) {
if (!it) {
Toast.makeText(
context,
"CHECK YOUR INTERNET CONNECTION",
Toast.LENGTH_LONG
).show()
} else {
navController.navigate(
route = "onlinePlayer/${song.songName}/${song.songArtist}" +
"/${
URLEncoder.encode(
song.link,
StandardCharsets.UTF_8.toString()
)
}" +
"/${
URLEncoder.encode(
song.image,
StandardCharsets.UTF_8.toString()
)
}"
)
}
}
}