Android Question [Solved] Initialize MobileAds

asales

Expert
Licensed User
Longtime User
In this link:
https://developers.google.com/admob/android/quick-start#initialize_mobileads
I have this information:
Before loading ads, have your app initialize the Mobile Ads SDK by calling MobileAds.initialize() with your AdMob App ID. This needs to be done only once, ideally at app launch.

I use banners, interstitial and native ads.
I need to do this?
If yes, how I can initialize the AdMob App ID?

Thanks in advance for any help.
 
Seems like the ads work without this call. You can call it with:
Code: Copy
Dim ctxt As JavaObject
ctxt.InitializeContext
MobileAds.InitializeStatic("com.google.android.gms.ads.MobileAds")
MobileAds.RunMethod("initialize", Array(ctxt, YourAdMobAppId))

Best to do it in Activity_Create when FirstTime is True.
 
Last edited:
Upvote 0
Upvote 0
This is my final code. Thanks!

Code: Copy
If FirstTime Then
    Dim ctxt As JavaObject
    ctxt.InitializeContext
    Dim MobileAds As JavaObject
    MobileAds.InitializeStatic("com.google.android.gms.ads.MobileAds")
    MobileAds.RunMethod("initialize", Array(ctxt, "ca-app-pub-3940256099942544~3347511713"))  'Sample ID
End If
 
Upvote 0
Upvote 0
I still don't have the ability to select/see Native ads when going to the "Add unit". Not sure why but a lot of people don't see it.
 
Upvote 0
I still don't have the ability to select/see Native ads when going to the "Add unit". Not sure why but a lot of people don't see it.
This is not still release to all users.
I talked with a Google account manager and he says that you will see this ads only if your account has a manager.
 
Upvote 0
Back
Top