CustomEventInterstitial

interface CustomEventInterstitial : CustomEvent


支持插页式广告的自定义事件。

自定义事件的典型生命周期是调用一次 requestInterstitialAd。此时,适配器应请求广告,并向监听器报告 onAdLoaded 或 onAdFailedToLoad。后续请求将使用新的自定义事件实例发出。在生命周期结束时,系统会尽力调用 onDestroy,但无法保证一定能调用。请注意,requestInterstitialAd 是在界面线程上调用的,因此适用于在该线程上编写代码的所有标准预防措施也适用于此方法。具体而言,代码不应调用任何阻塞方法。

自定义事件应通过 requestInterstitialAd 调用中传入的 CustomEventInterstitialListener 转发事件。制作广告请求所需的所有参数都应在 serverParameterMediationAdRequest customEventExtras 参数中传递。

摘要

公共函数

Unit
requestInterstitialAd(
    context: Context!,
    listener: CustomEventInterstitialListener!,
    serverParameter: String?,
    mediationAdRequest: MediationAdRequest!,
    customEventExtras: Bundle?
)

由中介库调用以请求插页式广告。

Unit

显示插页式广告。

继承的函数

来自 com.google.android.gms.ads.mediation.customevent.CustomEvent
Unit

拆除适配器控制。

Unit

当应用调用 pause 时调用。

Unit

当应用调用 resume 时调用。

公共函数

requestInterstitialAd

fun requestInterstitialAd(
    context: Context!,
    listener: CustomEventInterstitialListener!,
    serverParameter: String?,
    mediationAdRequest: MediationAdRequest!,
    customEventExtras: Bundle?
): Unit

由中介库调用以请求插页式广告。

如果请求成功,则应调用 onAdLoaded

如果请求失败,则应使用适当的错误原因对 listener 调用 onAdFailedToLoad。

此方法在界面线程上调用,因此适用于在该线程上编写代码的所有标准预防措施。特别是,您的代码不应调用任何阻塞方法。

参数
context: Context!

请求自定义事件插页式广告的 com.google.android.gms.ads.interstitial.InterstitialAdContext。最好使用 android.app.Activity

listener: CustomEventInterstitialListener!

监听自定义事件,并针对各种事件提供回调。

serverParameter: String?

在发布商界面中配置为自定义事件参数的字符串。

mediationAdRequest: MediationAdRequest!

请求插页式广告时要使用的通用定位参数。

customEventExtras: Bundle?

发布商根据具体请求设置的参数的 Bundle

showInterstitial

fun showInterstitial(): Unit

显示插页式广告。可以在调用 onAdLoaded 之后的任何时间调用此方法。