捕获在JavaScript的PhoneGap GapViewClient.onReceivedError [英] Catching phonegap GapViewClient.onReceivedError in javascript

查看:208
本文介绍了捕获在JavaScript的PhoneGap GapViewClient.onReceivedError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的PhoneGap Android应用程序是离线,我尝试访问URL的应用程序显示错误(GapViewClient.onReceivedError)消息框和关闭。我如何捕获错误显示,并关闭我的应用程序之前。

When my phonegap android app is offline, and i try to access a url the app displays an error (GapViewClient.onReceivedError) messagebox and closes. How do I catch the error before it is displayed and closes my app.

推荐答案

下面code添加到您的onCreate功能,并创建了资产/ WWW /文件夹正确消息的html文件,

Add the below code to your onCreate function and and create a html file with proper message in the asset/www/folder

  webViewClient = new WebViewClient() {

        public void onReceivedError( WebView view, int errorCode, String description, String failingUrl)
        {
            appView.loadUrl("file:///android_asset/www/noConnection.html");
        }
    };

欲了解更多详情请访问:的http://tech.sarathdr.com/featured/how-to-get-url-not-reached-error-in-anodroid-phonegap

这篇关于捕获在JavaScript的PhoneGap GapViewClient.onReceivedError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆