这个项目能做什么

AgentWeb 是一个基于 Android WebView 的库,旨在简化 WebView 的使用,提供强大且灵活的功能。它解决了 Android WebView 开发中的常见问题,如进度条、错误页、文件选择等,并支持自定义中间件。 ## 主要特性 - **易用性**:通过 `AgentWeb.with()` 链式调用快速集成。 - **功能丰富**:内置进度条、错误页、文件选择器(可选)、下载器等。 - **灵活性**:支持中间件(MiddlewareWebClientBase / MiddlewareWebChromeBase)叠加自定义逻辑。 - **轻量**:核心库体积小,按需引入可选模块。 ## 快速开始 1. 添加 JitPack 仓库(Gradle 7+ 在 `settings.gradle` 中配置)。 2. 添加依赖: ```groovy implementation 'com.github.Justson.AgentWeb:agentweb-core:5.1.7-androidx' // 必选 implementation 'com.github.Justson.AgentWeb:agentweb-filechooser:5.1.7-androidx' // 可选 implementation 'com.github.Justson:Downloader:v5.0.6-androidx' // 可选 ``` 3. 在 Activity/Fragment 中初始化: ```java AgentWeb.with(this) .setAgentWebParent(container, new LinearLayout.LayoutParams(...)) .useDefaultIndicator() .createAgentWeb() .ready() .go("https://example.com"); ``` ## 注意事项 - 不要直接对 WebView 调用 `setWebViewClient()` / `setWebChromeClient()`,应使用 AgentWeb 提供的方法或中间件。 - `setOpenOtherPageWays(ASK)` 仅在目标 App 已安装时弹窗。 - 处理非 http/https scheme 时可能触发隐私检测,可设置 `DISALLOW` 避免。 - 需要 AppCompat 主题支持 `AlertDialog`。 - 从 v5.1.2 起,compileSdk/targetSdk 升级到 36,AGP 需同步升级。 - v5.1.3 起已内置 `@JavascriptInterface` 的 keep 规则,无需重复声明。 ## 相关项目 - [flying-pigeon](https://github.com/Justson/flying-pigeon):跨进程 IPC 组件。 - [AgentWebX5](https://github.com/Justson/AgentWebX5):腾讯 X5 内核适配。 - [CoolIndicator](https://github.com/Justson/CoolIndicator):WebView 进度条。 - [Downloader](https://github.com/Justson/Downloader):轻量文件下载器。 ## 文档与支持 - [Wiki](https://github.com/Justson/AgentWeb/wiki)(不完整) - Sample 示例(推荐) - [更新日志](./releasenote.md) - 问题反馈:[Issues](https://github.com/Justson/AgentWeb/issues) - QQ 群:599471474 ## 许可证 Apache License 2.0。