本文介绍了如果未找到 Wi-Fi AP,则不会调用 NetworkCallback 的 onUnavailable() 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我正在尝试将我的智能手机连接到由 IOT 设备制作的 AP.我正在使用带有 NetworkCallback 的connectivitymanager.requestNetwork() 并且一切正常,直到我一直关闭我的AP 并且显然requestNetwork() 没有找到任何网络.那时,当我按下 Cancel 时,我希望 onUnavailable() 被调用,但应用程序仍处于空白屏幕.这是我的代码:

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()
             }

         }

如果手机没有找到 AP,我可以执行什么来返回到之前的活动?感谢您的帮助.


What can I implement to get back to the previous activity if the phone doesn't find the AP? Thanks for your help.

推荐答案

我在 Google Issue 上发布了这个问题,一段时间后他们将这个错误标记为已修复.它将在未来的版本中提供.

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.

这篇关于如果未找到 Wi-Fi AP,则不会调用 NetworkCallback 的 onUnavailable() 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-08 05:55