Stay organized with collections
Save and categorize content based on your preferences.
This page covers the instructions to handle callbacks from a background thread.
The Next Gen Mobile Ads SDK runs ad load and event callbacks on a background
thread. When performing UI-related operations within these callbacks, ensure you
explicitly dispatch them to the UI thread.
The following examples add a banner view to view hierarchy after an ad loads:
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["| **Last updated:** January 10, 2025\n\n\u003cbr /\u003e\n\nThis page covers the instructions to handle callbacks from a background thread.\n\nThe Next Gen Mobile Ads SDK runs ad load and event callbacks on a background\nthread. When performing UI-related operations within these callbacks, ensure you\nexplicitly dispatch them to the UI thread.\n\nThe following examples add a banner view to view hierarchy after an ad loads: \n\nKotlin \n\n```kotlin\nBannerAd.load(\n adRequest,\n object : AdLoadCallback\u003cBannerAd\u003e {\n override fun onAdLoaded(ad: BannerAd) {\n // Add the banner view to the view hierarchy on the UI thread.\n activity?.runOnUiThread {\n binding.bannerViewContainer.addView(ad.getView(requireActivity()))\n }\n }\n },\n)\n```\n\nJava \n\n```java\nBannerAd.load(\n adRequest,\n new AdLoadCallback\u003cBannerAd\u003e() {\n @Override\n public void onAdLoaded(@NonNull BannerAd ad) {\n // Add the banner view to the view hierarchy on the UI thread.\n runOnUiThread(\n () -\u003e binding.bannerViewContainer.addView(ad.getView(MainActivity.this)));\n }\n });\n```"]]