问题
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