【问题标题】:View Android webview network requests that occurred on page load in Chrome devtools在 Chrome devtools 中查看页面加载时发生的 Android webview 网络请求
【发布时间】:2019-09-19 13:13:29
【问题描述】:

如果您在 Android 中打开了 Web 视图,则可以在 Chrome 开发工具中对其进行检查。但是,我不能先打开 devtools,然后打开 webview 来记录页面加载时发生的网络请求。有没有办法记录 webview 加载后立即发生的网络请求?

此外,刷新页面的行为与初始加载不同,因为页面修改了 URL。

【问题讨论】:

  • 如果您锁定/解锁设备会怎样?
  • @MBDevelop 那将如何工作?我仍然需要在锁定设备之前打开 webview
  • 为什么不使用 window.location 将位置改回原来的 URL?
  • @Kyle 东西在加载时运行
  • 实际上,我认为您是对的,这可以工作。不太理想,但我会试试,谢谢

标签: javascript android google-chrome


【解决方案1】:

您可以通过实现自己的WebViewClient 来拦截WebView 通信的各种组件。下面是一个简短的 sn-p:

webView.webViewClient = object : WebViewClient() {

    override fun shouldInterceptRequest(view: WebView,
        request: WebResourceRequest): WebResourceResponse? {
        // Use the `request` object as needed.
    } 
}

有关WebViewClient 的更多信息,包括其他可能的覆盖,请访问here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-24
    • 2021-09-19
    • 1970-01-01
    • 2018-08-31
    • 2019-07-20
    • 1970-01-01
    • 2018-06-07
    • 2015-03-03
    相关资源
    最近更新 更多