I am trying to connect my smartphone to an AP made by an IOT device. I'm using connectivitymanager.requestNetwork() with a NetworkCallback and all works fine until I keep turned off my AP and obviuosly requestNetwork() doesn't find any network. At that point when I press Cancel I expected that onUnavailable() is called but instead the app remains at a blank screen. Here's my code:
connectivityManager?.requestNetwork(networkRequest, object : ConnectivityManager.NetworkCallback()
{
override fun onAvailable(network: Network)
{
connectivityManager.bindProcessToNetwork(network)
var intent= Intent(this@WifiDiCEActivity, ConnectDiCEActivity::class.java)
startActivity(intent)
finish()
}
override fun onUnavailable()
{
super.onUnavailable()
var intent= Intent(this@WifiDiCEActivity, AddDiCEStep3Activity::class.java)
startActivity(intent)
finish()
}
override fun onLost(network: Network)
{
super.onLost(network)
var intent= Intent(this@WifiDiCEActivity, AddDiCEStep3Activity::class.java)
startActivity(intent)
finish()
}
}
What can I implement to get back to the previous activity if the phone doesn't find the AP? Thanks for your help.
I posted this problem on Google Issue, and after some time they have marked this bug as fixed. It will become available in a future release.