Overview
Display backfill ads in your WebView by registering it with the Adrop SDK. This allows web content within your app to show ads through the Adrop platform.
AndroidManifest.xml Configuration
Add the following to your AndroidManifest.xml to enable backfill ads in WebView:
<manifest>
<application>
<!-- WebView Backfill Ad Integration -->
<meta-data
android:name="com.google.android.gms.ads.INTEGRATION_MANAGER"
android:value="webview"/>
</application>
</manifest>
This configuration is required for backfill ads to work properly in WebView. Without it, backfill ads may not display.
Register WebView
import android.webkit.WebView
import io.adrop.ads.Adrop
class WebViewActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val webView = findViewById<WebView>(R.id.webView)
// Register WebView for backfill ads support
// Call as early as possible, before loading content
Adrop.registerWebView(webView)
// Load your web content
webView.loadUrl("https://your-website.com")
}
}
registerWebView() automatically configures optimal WebView settings:
- JavaScript enabled
- DOM storage enabled
- Media playback without user gesture
- Third-party cookies enabled
Call this method on the main thread, as early as possible (e.g., in onCreate).
Backfill ads in WebView requires adrop-ads-backfill module. If the module is not installed, registerWebView() is silently ignored.