Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
constructor(adView: AdView?, context: Context) {
this.adView = adView
this.context = context
interstitialAd = InterstitialAd(context)
interstitialAd.adUnitId = GameSettings.ADMOB_INTERSTITIAL_ID
interstitialAd.adListener = object : AdListener() {
override fun onAdClosed() {
requestNewInterstitial()
super.onAdClosed()
}
}
requestNewInterstitial()
handler = object : Handler() {
override fun handleMessage(msg: Message) {
when (msg.what) {
HIDE -> {
adView?.visibility = View.GONE
}
SHOW -> {
adView?.visibility = View.VISIBLE
}
}
}
}
}
private fun requestNewInterstitial() {
val adRequestBuilder = AdRequest.Builder()
adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
interstitialAd.loadAd(adRequestBuilder.build())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment