{"id":20441294,"url":"https://github.com/leavesster/android_webview_intercept","last_synced_at":"2026-04-19T01:38:17.710Z","repository":{"id":155746606,"uuid":"279460045","full_name":"leavesster/Android_webView_intercept","owner":"leavesster","description":"Intercept Android webView request by WebViewClient","archived":false,"fork":false,"pushed_at":"2020-09-08T14:46:56.000Z","size":9782,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-05T07:46:06.986Z","etag":null,"topics":["webview","webviewclient"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/leavesster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-14T02:22:34.000Z","updated_at":"2024-09-12T09:18:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"eeafdf74-1eca-4139-9cdc-2e6881abfc07","html_url":"https://github.com/leavesster/Android_webView_intercept","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/leavesster/Android_webView_intercept","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavesster%2FAndroid_webView_intercept","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavesster%2FAndroid_webView_intercept/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavesster%2FAndroid_webView_intercept/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavesster%2FAndroid_webView_intercept/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/leavesster","download_url":"https://codeload.github.com/leavesster/Android_webView_intercept/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/leavesster%2FAndroid_webView_intercept/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31991720,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["webview","webviewclient"],"created_at":"2024-11-15T09:31:31.809Z","updated_at":"2026-04-19T01:38:17.683Z","avatar_url":"https://github.com/leavesster.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# webView 资源拦截\n\n## 资源\n\n在`app/src/main/assets`中已有一个网页和一个本地 mp4 资源。\n\n网页内容：\n\n1. local video 为直接通过 file 路径播放 Android `assets`中的视频。\n2. http video 为播放网络资源视频。\n\n## 使用\n\n1. 点击右上角【三点】按钮，选择【使用本地资源替换】，会将 http video 的 mp4 下载到本地，然后重载本地网页。此时由于应用中，已经有对应的视频资源，http video 的请求，将会被`LocalFileWebClient`拦截，将本地视频内容，返回给 webview。这些操作，可以在 logcat 使用 `download` 标签进行查看。\n    * 当未下载时，会提示 `not exsit`，当应用中存在视频时，会提示`request hit`\n1. 还可以点击【三点】按钮，选择【使用下载资源替换】，会将 http video 的 mp4 请求响应，替换成 Android `assets` 视频\n    * 此时不需要使用 logcat 查看日志，`assets`视频与 http video 资源不同\n\n\n## 与 iOS（WKWebView）不同点：\n\n1. Android 可以直接拦截 http 请求，不需要像 iOS 一样，使用自定义 scheme 请求进行拦截（iOS 11 API），或使用私有 API 进行拦截。\n2. Android 拦截时，可以进行选择回退，直接返回 null，就可以交由系统处理；iOS 不可以。\n3. iOS 使用私有 API 拦截 http 请求时，会造成 post 的 body 丢失，Android 也截取不到 body，但是可以通过回退交由系统处理。\n\n## Android 与 iOS 相同点\n\n1. 无法获取到 post 请求的 body 部分。\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavesster%2Fandroid_webview_intercept","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fleavesster%2Fandroid_webview_intercept","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fleavesster%2Fandroid_webview_intercept/lists"}