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!

请求自定义事件插页式广告的 Context。最好使用 android.app.Activity

listener: CustomEventInterstitialListener!

监听器,用于自定义事件,并包含各种事件的回调。

serverParameter: String?

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

mediationAdRequest: MediationAdRequest!

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

customEventExtras: Bundle?

发布商为每个请求设置的参数的 Bundle

showInterstitial

fun showInterstitial(): Unit

展示插页式广告。在调用 onAdLoaded 之后的任何时间都可能会调用此方法。