XuqmGroup-AndroidSDK/sdk-webview
XuqmGroup ade156456a fix(sdk-webview): handle WebView renderer crash to prevent main process from dying
onRenderProcessGone was not overridden, so when the WebView sandboxed
renderer process crashed (e.g. during file upload of docx), Android
terminated the main app process as well (default return false behavior).

Now: return true to keep the host app alive, report the renderer crash
via BugCollect (reflection, no compile-time dependency), and reload the
page so the user is not stuck on a blank screen.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-23 11:23:03 +08:00
..
src/main fix(sdk-webview): handle WebView renderer crash to prevent main process from dying 2026-06-23 11:23:03 +08:00
build.gradle.kts build: 各 SDK 模块独立版本,publish.gradle 改用 project.version 2026-05-21 16:48:10 +08:00
consumer-rules.pro chore: sync local changes 2026-05-07 19:39:38 +08:00
README.md docs: 添加 CLAUDE.md + 各 module README + sdk-webview JSBridge 补全 2026-06-16 12:14:54 +08:00

sdk-webview

XuqmGroup Android SDK WebView 模块。提供嵌入式 WebView 组件和独立页面,内置 JSBridge、文件选择、下载拦截。

依赖

implementation("com.xuqm:sdk-webview:VERSION")
implementation("com.xuqm:sdk-core:VERSION")  // 必须

使用

嵌入式组件

import com.xuqm.sdk.webview.XWebViewView
import com.xuqm.sdk.webview.XWebViewConfig

XWebViewView(
    config = XWebViewConfig(
        url = "https://example.com",
        title = "嵌入式网页",
    ),
)

独立页面

import com.xuqm.sdk.webview.openXWebView
import com.xuqm.sdk.webview.XWebViewConfig

openXWebView(XWebViewConfig(url = "https://example.com", title = "独立页面"))
// navigate("xwebview") 后使用 XWebViewScreen()

XWebViewConfig 参数

参数 类型 默认值 说明
url String "" 初始加载地址
title String "" 页面标题
hideToolbar Boolean false 隐藏顶栏
hideStatusBar Boolean false 隐藏状态栏
userAgent String? null 自定义 User-Agent
injectedJavaScript String? null 注入的 JS
jsBridgeName String "XWebViewBridge" JS 桥接对象名
debugEnabled Boolean false 开启远程调试
downloadDestination FileDownloadDestination Sandbox 下载存储目标
downloadNotificationTitle String? null 通知栏下载进度
onMessage (String) -> Unit? null H5 消息回调

JSBridge 通信

// H5 → Native
window.XWebViewBridge.postMessage(JSON.stringify({ type: 'login', token: '...' }))

// 监听下载进度
window.addEventListener('__xwvDownloadProgress', (e) => { ... })
window.addEventListener('__xwvDownloadDone', (e) => { ... })

文件选择与拍照

  • <input type="file"> + accept="image/*" + capture → 系统相机
  • <input type="file"> + .docx/.xlsx → 文件选择器
  • getUserMedia() WebRTC → 自动请求 CAMERA 权限