webViewClientのonReceivedErrorとかを使う。 webViewClient
public class MainActivity extends Activity{ WebView webview = new WebView(this); setContentView(webview); webview.loadUrl("http://example.com/"); webview.setWebViewClient(new webViewClient(){ @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl){ Log.e("Log", "errorCode: " + String.valueof(errorCode)); Log.e("Log", "description: " + description); Log.e("Log", "failingUrl: " + +failingUrl); } }); } }
ErrorCode | ||
---|---|---|
int | ERROR_AUTHENTICATION | User authentication failed on server |
int | ERROR_BAD_URL | Malformed URL |
int | ERROR_CONNECT | Failed to connect to the server |
int | ERROR_FAILED_SSL_HANDSHAKE | Failed to perform SSL handshake |
int | ERROR_FILE | Generic file error |
int | ERROR_FILE_NOT_FOUND | File not found |
int | ERROR_HOST_LOOKUP | Server or proxy hostname lookup failed |
int | ERROR_IO | Failed to read or write to the server |
int | ERROR_PROXY_AUTHENTICATION | User authentication failed on proxy |
int | ERROR_REDIRECT_LOOP | Too many redirects |
int | ERROR_TIMEOUT | Connection timed out |
int | ERROR_TOO_MANY_REQUESTS | Too many requests during this load |
int | ERROR_UNKNOWN | Generic error |
int | ERROR_UNSUPPORTED_AUTH_SCHEME | Unsupported authentication scheme (not basic or digest) |
int | ERROR_UNSUPPORTED_SCHEME | Unsupported URI scheme |
JavaScriptのコンソール出力をLogcatに出す
ActivityでJavascriptを実行可に設定
WebView webview =new WebView(this); webview.getSettings().setJavaScriptEnabled(true); setContentView(webview);
javascript内でconsole.logを
<script> console.log('test!!'); </script>