Where should i call MobileAds.initialize()?

后端 未结 3 1779
失恋的感觉
失恋的感觉 2021-02-20 02:49

I have read https://developers.google.com/admob/android/quick-start?hl=en-US#import_the_mobile_ads_sdk

I need to initialize MobileAds using Code A in order to display Ad

3条回答
  •  臣服心动
    2021-02-20 03:20

    MobileAds.initialize(this, "YOUR-APP-ID") has deprecated. Use the below code instead.

    import android.app.Application
    import com.google.android.gms.ads.MobileAds
    
    class MyApp: Application() {
    
       override fun onCreate() {
           MobileAds.initialize(applicationContext)
           super.onCreate()
       }
    
    }
    

提交回复
热议问题