A minimal Android app that embeds the Molin AI chat widget in a WebView. Zero third-party dependencies beyond AndroidX AppCompat.
app/src/main/
java/ai/molin/widget/
MainActivity.kt — loads the WebView on launch with widget.html
assets/
widget.html — loads the Molin AI chat widget from CDN
res/
layout/activity_main.xml — fullscreen WebView layout
AndroidManifest.xml — app manifest with INTERNET permission
- Open the project in Android Studio
- Replace
YOUR_WIDGET_IDinapp/src/main/assets/widget.htmlwith your widget ID from the Molin dashboard - Run on an emulator or device (API 24+)
The app loads a bundled HTML file (widget.html) in an Android WebView. The HTML loads the Molin widget script from CDN and renders <molin-shop-ai-chat> fullscreen.
The HTML includes a proper viewport meta tag, CSS reset, and fullscreen sizing to ensure the widget renders correctly across all Android versions and screen densities.
The show-close attribute on <molin-shop-ai-chat> renders a close button in the chat header. When tapped, the widget fires a molin-shop-ai-chat:close-click event. The HTML handles this by navigating to molin://close:
document.addEventListener('molin-shop-ai-chat:close-click', function () {
window.location.href = 'molin://close';
});The native side intercepts molin:// URLs via WebViewClient.shouldOverrideUrlLoading and calls finish() to close the activity. This is the same pattern used in the iOS example with WKNavigationDelegate.
- Widget ID — change the
widgetattribute inwidget.html - Close behavior — modify the
molin://closehandler inMainActivity.kt
MIT