Android Integration
Embed DocQA in an Android app using WebView.
WebView Setup
kotlin
val webView = findViewById<WebView>(R.id.webView)
webView.settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
mixedContentMode = WebSettings.MIXED_CONTENT_NEVER_ALLOW
}
webView.webViewClient = WebViewClient()Loading the Widget
Option 1 — Load your website (widget is already embedded):
kotlin
webView.loadUrl("https://yoursite.com")Option 2 — Load the widget directly via inline HTML:
kotlin
val html = """
<!DOCTYPE html>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1.0"></head>
<body>
<script
src="https://widget.webnav.ai/widget/chat-widget.js"
data-base-url="https://yoursite.com"
data-theme="light"
data-lang="en"
></script>
</body>
</html>
""".trimIndent()
webView.loadDataWithBaseURL("https://yoursite.com", html, "text/html", "UTF-8", null)Permissions
Add internet permission to AndroidManifest.xml:
xml
<uses-permission android:name="android.permission.INTERNET" />ProGuard
No special ProGuard rules are needed. The widget runs entirely in the WebView.
Troubleshooting
| Issue | Solution |
|---|---|
| Widget not loading | Ensure javaScriptEnabled = true |
| SSL errors | Use mixedContentMode = MIXED_CONTENT_NEVER_ALLOW |
| Blank screen | Check domStorageEnabled = true |