How universal-uclick/html5-games-example-android works
Project type and purpose
• This is an Android sample application whose sole purpose is to demonstrate how to integrate Universal Uclick’s HTML5 Games into an Android WebView. It is a lightweight, single-Activity app with a Fragment, some resource files, and supporting libraries—no backend or database of its own.
File structure
• Top-level files:
• AndroidManifest.xml (declares the app’s entry points & permissions)
• project.properties / proguard-project.txt (build configuration)
• readme.markdown (integration instructions)
• Directories:
• src/com/universaluclick/HTMLGamesExample
– MainActivity.java (hosts the Fragment)
• res/layout, res/values, res/drawable-*dpi (UI layouts, strings, styles, dimensions, images)
• libs/android-support-v4.jar (Fragment support)
Extract insights from README
• MainActivity (and its inner HtmlGameFragment) builds an HTML string with embedded JavaScript that:
• injects the Universal Uclick game engine via a dynamically created <iframe>
• customizes that JS using package name, client ID, auth key, and game key (all set in res/values/strings.xml)
• That HTML is loaded into the WebView in onCreateView().
a. Main components to represent:
• Android Platform (OS & WebView component)
• Your Application APK
– MainActivity
– HtmlGameFragment
– Java “HTML+JS builder” module
– Android Resources (strings.xml, layouts, drawables)
– Support Library
• External Universal Uclick Game Engine Service (hosted on Uclick servers)
b. Relationships & interactions:
1. Android OS launches your APK → MainActivity
2. MainActivity instantiates HtmlGameFragment
3. HtmlGameFragment.onCreateView() calls Java code to assemble an HTML string using values from strings.xml
4. WebView.loadDataWithBaseURL() injects that HTML/JS into the native WebView widget
5. WebView’s JS runtime fetches the Uclick game engine script from the external service
6. The script dynamically creates an <iframe> pointing to the actual HTML5 game page (crossword/sudoku/etc.)
c. Architectural patterns & design principles:
• Layered separation:
– Presentation Layer (Activity/Fragment + XML layouts)
– Integration Layer (WebView bridge, HTML/JS builder)
– External Service Layer (Universal Uclick’s servers)
• Configuration externalized in resources (strings.xml)
• Minimal native logic—delegates game rendering to HTML5/JS
d. Key technologies & libraries:
• Java + Android SDK
• Android Support Library v4 (for Fragment)
• Android WebView (controls Java–JavaScript bridge)
• XML resource system (layouts, values, drawables)
• HTML5/JavaScript game engine loaded over the network