Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个带有 WebViewClient 且设置了 onRecievedError 方法的 WebView。
但是如果我将手机设置为飞行模式,页面加载失败,上面的方法没有被调用,有没有办法检测和处理WebView无法加载页面?
但是,如果我将手机设置为飞行模式并且页面无法加载,则不会调用上述方法
该方法适用于从 Web 服务器接收到的错误。在您的情况下,没有可访问的 Web 服务器。
是否有任何检测和处理 WebView 无法加载页面的方法?
不是一般的,AFAIK。您可以使用它ConnectivityManager来确定您是否有 Internet 连接,这将有助于您的飞行模式场景。
ConnectivityManager