Android Smart WebView 7.1 🎉 (Plugins Release)
This is a landmark release for Smart WebView! Version 7.1 introduces a powerful and flexible plugin architecture, transforming Smart WebView from a simple web wrapper into an extensible foundation for building advanced hybrid applications.
This new system allows developers to add complex native features as modular, self-contained units without altering the core project code. This makes customization easier, updates cleaner, and opens the door for a new ecosystem of premium, high-value features.
✨ What's New: The Plugin Architecture
The core of this update is a new set of components designed for maximum extensibility:
🔌 Plugin Manager (PluginManager.java): A central hub that handles the registration, initialization, and lifecycle of all active plugins. It ensures that plugins have safe access to the app's context and WebView instance.
🧩 Standardized Interface (PluginInterface.java): A clear contract that all plugins must implement. It defines essential methods for initialization, event handling (onActivityResult, onRequestPermissionsResult), and WebView interaction (shouldOverrideUrlLoading, onPageFinished).
🚀 Self-Registration: Plugins are now self-registering. By simply including a plugin's source file in the project, its static initializer block automatically registers it with the PluginManager on app startup.
🧪 The Playground (Playground.java): A dedicated class for developers to test, configure, and debug plugins in a sandboxed environment. It includes fail-safe diagnostic tools and a method for injecting a demo UI into the WebView for easy manual testing.
⚙️ Centralized Configuration: Plugins can now be enabled or disabled globally (ASWP_PLUGINS) or individually via the ASWP_PLUGIN_SETTINGS map in SmartWebView.java. This allows for fine-grained control over which features are active.
Example Plugin Included
🍞 ToastPlugin: To demonstrate the new architecture and provide a template for developers, a simple ToastPlugin is included in the open-source project. It shows how to create a plugin, implement the interface, register it, and create a JavaScript bridge.
💎 Premium Plugins Now Available
This new architecture enables us to offer a suite of powerful, ready-to-use premium plugins for GitHub Sponsors. These are designed to drop into your project and work with minimal setup:
- AdMob: Easily integrate banner, interstitial, and rewarded video ads.
- Biometric Authentication: Secure your app with fingerprint or face unlock.
- QR/Barcode Scanner: Add in-app code scanning using the device camera.
- Image Compression: Automatically compress images before uploading to save bandwidth.
- JS Bridge: A more robust two-way communication bridge between native code and JavaScript.
🐛 Fixes & Improvements
This release also includes several important fixes and modernizations:
- [Fixed] File Upload Callback: Resolved a critical issue where the file chooser callback (
asw_file_path) could be lost, preventing file uploads from completing. The entire file handling logic has been modernized to use theActivityResultLauncher, making it more reliable and removing deprecatedstartActivityForResultcalls. - [Fixed] FCM Notification Clicks: Corrected an issue where tapping a notification might not properly open the specified URL. The intent handling for notifications is now more robust.
- [Fixed] Location Service Stability: Improved the GPS tracking logic in
GPSTrack.javato handle cases where a location provider is unavailable, preventing potential null pointer exceptions. - [Improved] Permission Handling: Refactored permission requests to be more streamlined and context-aware, especially for file and camera access on modern Android versions.
- [Improved] URL Handling: The logic for distinguishing internal vs. external URLs (
aswm_host) has been refined for better accuracy. - [Improved] Code Modernization: Updated various parts of the codebase to use modern Android practices, including stricter type checking, better error logging, and improved resource management. The project now targets Android 14 (SDK 35).
For Developers
- To create your own plugin, simply create a new class that implements
PluginInterfaceand add a static block for self-registration. SeeToastPlugin.javafor a complete example. - The
Playground.javaclass is the best place to start for testing your new plugins. Add your plugin to the diagnostic checks and the demo UI. - All plugins are disabled by default if the global
ASWP_PLUGINSflag is set tofalse. You can also toggle individual plugins in theASWP_PLUGIN_SETTINGSmap.
A massive thank you to our community and sponsors for making this evolution possible. We're excited to see what you build with the new plugin system.