2017-02-25 86 views

回答

0

是的,你可以做到這一點通過初始化類裏面以下瓦爾

internal lateinit var mInterstitialAd: InterstitialAd 
internal lateinit var adRequest : AdRequest 

和開始覆蓋樂趣的onCreate內的AdRequest中具有以下代碼

mInterstitialAd = InterstitialAd(this); 
mInterstitialAd.adUnitId = " YOUR INTERSTITIAL ID"; 
adRequest = AdRequest.Builder() 
    .build(); 
mInterstitialAd.loadAd(adRequest); 
mInterstitialAd.adListener = object : AdListener() { 

@Override public override fun onAdLoaded() { 
    requestNewInterstitial() 
    } 
}; 

訪問此鏈接的完整的AdMob使用和集成使用Kotlin:Tutorial

0
lateinit var interstitialAd: InterstitialAd 
    lateinit var adRequest: AdRequest 

    interstitialAd = InterstitialAd(this) 
    interstitialAd.adUnitId = getString(R.string.admob_interstitial) 
    adRequest = AdRequest.Builder().build() 
    interstitialAd.loadAd(adRequest) 

    interstitialAd.adListener = object : AdListener() { 
     override fun onAdLoaded() { 
      if (interstitialAd.isLoaded) { 
       interstitialAd.show() 
      } 

     } 


    } 
相關問題