If you have a webview open in Android, you can inspect it in Chrome devtools. However, I can't open the devtools first, then open the webview to log network requests that occur on page load. Is there a way to log network requests that occur as soon as the webview loads?
Also, refreshing the page behaves differently from the initial load because the page modifies the URL.
# Open a WebView in DevToolsThe chrome://inspect page displays a list of debug-enabled WebViews on your device. To start debugging, click inspect below the WebView you want to debug. Use DevTools as you would for a remote browser tab.
Overiding shouldOverrideUrlLoading inside WebViewClient implementation will open link in same window. webView. setWebChromeClient(new WebChromeClient() { @Override public boolean onCreateWindow(WebView view, boolean isDialog, boolean isUserGesture, Message resultMsg) { WebView newWebView = new WebView(WebpageActivity.
Open an Android WebView in DevTools To display a list of the Android WebViews with debugging turned on that run on your device, go to edge://inspect . To start debugging, under the Android WebView you want to debug, click inspect. Use DevTools in the same way that you use a remote browser tab.
The loadUrl() and loadData() methods of Android WebView class are used to load and display web page.
You can intercept various components of WebView communication by implementing your own WebViewClient
. A short snippet is below:
webView.webViewClient = object : WebViewClient() {
override fun shouldInterceptRequest(view: WebView,
request: WebResourceRequest): WebResourceResponse? {
// Use the `request` object as needed.
}
}
More information regarding the WebViewClient
, including other possible overrides, can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With