Hi Vishal,
Thank you for contacting the Mobile Ads SDK support team.
Yes, you can get the appEvent() before onAdLoaded() callback on GAM SDKs banner ads. You can listen for Ad Manager specific app events using AppEventListener. These events can occur at any time during the ad's lifecycle, even before onAdLoaded() is called. void onAppEvent(String name, String info) is called when an app event occurs in an ad. This interface can be implemented by your activity or any other object:
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
fragmentBinding.appeventsAvMain.appEventListener = AppEventListener { name, data ->
// The Ad Manager ad that this fragment loads contains JavaScript code that sends App
// Events to the host application. This AppEventListener receives those events,
// and sets the background of the fragment to match the data that comes in.
// The ad will send "red" when it loads, "blue" five seconds later, and "green"
// if the user taps the ad.
// This is just a demonstration, of course. Your apps can do much more interesting
// things with App Events.
if (name == "color") {
val color =
when (data) {
"blue" -> Color.rgb(0xD0, 0xD0, 0xFF)
"red" -> Color.rgb(0xFF, 0xD0, 0xD0)
else -> Color.rgb(0xD0, 0xFF, 0xD0) // Green.
}
fragmentBinding.root.setBackgroundColor(color)
}
}
val adRequest = AdManagerAdRequest.Builder().build()
fragmentBinding.appeventsAvMain.loadAd(adRequest)
}
Remember to set the delegate using the appEventDelegate property before making the request for an ad. I cannot comment on the API part because we can only assist with technical queries/concerns related to the Google Mobile Ads SDK. Also, refer to the Android API Demo app for an example of the implementation of app events.
![]() |
Mobile Ads SDK Team |