android 互联网连接错误失败
android internet connection error fails
您好,如果互联网连接失败,我会尝试向用户显示一个服装文件。在这种情况下,它工作正常。如果 Internet 连接正常并且 index.php
已加载,则在此之前一切正常。
如果我点击 index.php
上的按钮,用户被重定向到另一个页面,说我们 login.php
服装错误文件启动。那很糟。为什么文件 myerrorpage.html 只在 internet 连接失败而不是项目文件更改时显示?
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_localy);
mWebView = (WebView) findViewById(R.id.webview);
// Brower niceties -- pinch / zoom, follow links in place
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.setWebViewClient(new GeoWebViewClient());
// Below required for geolocation
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setGeolocationEnabled(true);
mWebView.setWebChromeClient(new GeoWebChromeClient());
// Load google.com
mWebView.loadUrl("http://192./loc/index.php");
super.onCreate(savedInstanceState); mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
mWebView.loadUrl("file:///android_asset/myerrorpage.html");
}
});
}
From,
Report web resource loading error to the host application. These errors usually indicate inability to connect to the server. Note that unlike the deprecated version of the callback, the new version will be called for any resource (iframe, image, etc), not just for the main page. Thus, it is recommended to perform minimum required work in this callback.
此方法不是检查 Internet 连接问题的最佳方法。您可以手动检查 Internet 连接并加载错误页面。
您好,如果互联网连接失败,我会尝试向用户显示一个服装文件。在这种情况下,它工作正常。如果 Internet 连接正常并且 index.php
已加载,则在此之前一切正常。
如果我点击 index.php
上的按钮,用户被重定向到另一个页面,说我们 login.php
服装错误文件启动。那很糟。为什么文件 myerrorpage.html 只在 internet 连接失败而不是项目文件更改时显示?
@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_localy);
mWebView = (WebView) findViewById(R.id.webview);
// Brower niceties -- pinch / zoom, follow links in place
mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
mWebView.setWebViewClient(new GeoWebViewClient());
// Below required for geolocation
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setGeolocationEnabled(true);
mWebView.setWebChromeClient(new GeoWebChromeClient());
// Load google.com
mWebView.loadUrl("http://192./loc/index.php");
super.onCreate(savedInstanceState); mWebView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
mWebView.loadUrl("file:///android_asset/myerrorpage.html");
}
});
}
From,
Report web resource loading error to the host application. These errors usually indicate inability to connect to the server. Note that unlike the deprecated version of the callback, the new version will be called for any resource (iframe, image, etc), not just for the main page. Thus, it is recommended to perform minimum required work in this callback.
此方法不是检查 Internet 连接问题的最佳方法。您可以手动检查 Internet 连接并加载错误页面。