This document outlines how you can use Android WebViews to run our products inside your app.
This document has been written assuming you're integrating a Gamezop Unique Link or individual games. However, the steps to follow are the same even if you're integrating Quizzop / Astrozop or any of our other products in your app.
Integration guide
This guide applies to Android WebView integration only. Follow the steps given below closely to get a perfectly working WebView implementation in your app:
Step 1: Create the WebView via code (instead of XML)
We recommend creating the WebView in code for simplicity. To prevent memory leaks, make sure to call destroy() on the WebView in the Activityβs onDestroy().
You may have a particular Android Activity where you place the Gamezop icon / banner. When a user taps on that icon / banner, you want to open your game URL within a WebView. Within the onCreate method of this Activity, you will have to create the WebView as mentioned below:
// At the top of your Activity class:privateWebViewmyWebView;// In onCreate():@OverrideprotectedvoidonCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState); myWebView =newWebView(this);setContentView(myWebView);}
Step 2: Make updates to AndroidManifest.xml
The primary objective of making these updates is to enable the following:
Internet access for the WebView
Screen orientation changes within the WebView (since games can be landscape as well)
Hardware acceleration for better game performance
Here are the updates to be made within your app's AndroidManifest.xml file:
Using android:configChanges="orientation|screenSize" stops the activity from being recreated on rotation. Keep this attribute if your activity is simple and doesnβt need to restart during orientation changes, but for complex activities, it may be better to rely on the default configurationβchange handling.
Step 3: Setup a WebViewClient to intercept URLs
Create a CustomWebViewClient file within the same directory as where you have your MainActivity file. Java and Kotlin versions of this file are given below:
Step 4: Set this CustomWebViewClient as your WebView client
To do so, add the following line in the Activity where you created your WebView:
Step 5: Configure WebView settings in the holder Activity
Add the following lines in the Activity where you created your WebView:
To prevent memory leaks, always destroy the WebView when the activity or fragment that hosts it is destroyed.
Add the following line inside your activityβs onDestroy() method:
Destroying the WebView releases its internal resources (JavaScript threads, rendering cache, etc.) without clearing the shared application cache.
This keeps Gamezop games and other web content loading fast on subsequent visits while ensuring the app itself does not leak memory.
Step 6: Open your Gamezop Unique Link
Once you are done with the 5 steps mentioned above, you are ready to open your Gamezop game URL within your WebView. Add this line at the end of the Activity where you created your WebView:
Step 7: Integrate the WebView API for Ads
You can avoid this step if you are integrating Gamezop games or any of our other products with ads disabled. However, if you are working with us on our advertising revenue-share model, following this step is crucial for optimal ad monetisation.
The WebView Ads API shares app signals with Google ad tags used within Gamezop, helping optimise ad delivery and increase monetisation β which in turn boosts your revenue share.
Add the following <meta-data> tag in your AndroidManifest.xml file to bypass the check for the APPLICATION_ID. If you miss this step and don't provide the <meta-data> tag, the Google Mobile Ads SDK throws an IllegalStateException on app start.
Register the web view
Call registerWebView() on the main thread to establish a connection with the JavaScript handlers in the AdSense code or Google Publisher Tag within each WebView instance. This should be done as early as possible, such as in the onCreate() method of your MainActivity.
Cache and performance
WebView automatically caches Gamezopβs game assets and user cookies to make reloads much faster for returning users. To maintain this performance, avoid clearing the WebView cache or cookies unnecessarily.
β Best practice: Let WebView manage its own cache and cookie storage.
The WebView resource cache is shared across all WebViews within your app.
If you clear it frequently (for example, every time the WebView is destroyed), all downloaded game assets will need to be fetched again, increasing load times and data usage.
Test ads performance
Use this URL to test if your WebView is properly optimised for ad monetisation:
The test URL has success criteria for a complete integration if the following are observed:
WebView settings
Third-party cookies work
First-party cookies work
JavaScript enabled
DOM storage enabled
Video ad
The video ad plays inline and does not open in the full screen built-in player
The video ad plays automatically without clicking the play button
The video ad is replayable
WebView API for Ads
If you followed Step 7 above, visit this link in your app's WebView to check if it successfully connected to the Google Mobile Ads SDK. The test URL should show green status bars for a successful integration.
Optimal click behaviour
Open this link in your app's WebView. Click each of the different link types to see how they behave in your app. Here are some things to check:
Each link opens the intended URL.
When returning to the app, the test page's counter doesn't reset to zero to validate the page state was preserved.
After testing is complete, substitute the test URLs from Google with your Gamezop Unique Link.
myWebView.loadUrl("https://3025.play.gamezop.com") //ensure you replace this with the URL provided to you by your Gamezop Account Manager
myWebView.loadUrl("https://3025.play.gamezop.com"); //ensure you replace this with the URL provided to you by your Gamezop Account Manager
<!-- Bypass APPLICATION_ID check for web view APIs for ads -->
<meta-data
android:name="com.google.android.gms.ads.INTEGRATION_MANAGER"
android:value="webview"/>
import com.google.android.gms.ads.MobileAds
// After Step 5 (settings) and before/after Step 6 (loadUrl), simply register:
MobileAds.registerWebView(myWebView)
import com.google.android.gms.ads.MobileAds;
// After Step 5 settings (and before/after Step 6 loadUrl), register the same WebView:
MobileAds.registerWebView(myWebView);