Catching phonegap GapViewClient.onReceivedError in javascript

£可爱£侵袭症+ 提交于 2020-01-14 03:42:45

问题


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.


回答1:


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");
        }
    };

For more details visit: http://tech.sarathdr.com/featured/how-to-get-url-not-reached-error-in-anodroid-phonegap



来源:https://stackoverflow.com/questions/9475720/catching-phonegap-gapviewclient-onreceivederror-in-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!