Android Question Can't get MobileAds_Ready event

tufanv

Expert
Licensed User
Longtime User
Hello,

I realized that my app is not triggering mobileads_ready event anymore. I have checkconsentandaddads sub in the code, that sub is triggered, I check via logs but it doesnt get pass the waitfor mobileads_ready.

Is there any way to log what is the problem like mobileads_error ?

edit: I cleared everything on activity create, starter class etc. It is not working. I am going nuts..

Thanks
B4X:
Private Sub CheckConsentAndAddAds
    Log("here") ' this is triggered
    Dim m As MobileAds
    Wait For (m.Initialize) MobileAds_Ready
    LogColor("After MobileAds_Ready", Colors.Magenta)
    '    builder.AddTestDevice("C2636212A08D5A3629DC75E8D1810196")
        Dim jo As JavaObject
jo.InitializeStatic("com.google.android.gms.ads.MobileAds")
jo.RunMethod("setAppMuted", Array(True))


    m.SetConfiguration(m.CreateRequestConfigurationBuilder(Array("C2636212A08D5A3629DC75E8D1810196"))) 'optional. Array with test device ids. See unfiltered logs to find correct id.
   
'    ads.ResetConsentStatus
'    ads.SetConsentDebugParameters("C2636212A08D5A3629DC75E8D1810196", True) 'same id as above
   
    If ads.GetConsentStatus = "UNKNOWN" Then
        Wait For (ads.RequestConsentInformation(False)) Complete (Success As Boolean)
    End If
    If ads.GetConsentStatus = "REQUIRED" And ads.GetConsentFormAvailable Then
        Wait For (ads.ShowConsentForm) Complete (Success As Boolean)
    End If
'    Log("Consent: " & ads.GetConsentStatus)
    LoadAd
End Sub
 
Last edited:

tufanv

Expert
Licensed User
Longtime User
an update: If I remove wait for mobileads_ready and instead insert sleep(1500), the code works. So somehow, mobileads_ready is not trigerred although it is initialized. Why can this happen ? ( If I dont use sleep, as m is not yet initialized. it doesnt log the consent status so with sleep it works.)
 
Last edited:
Upvote 0

tufanv

Expert
Licensed User
Longtime User
I was calling it from the activity_create. I moved it to starter service to test, I am not waiting for the event to fire, but this time it works because ıt logs the consent status. The example of Jack Cole for activity based apps calls it from the create and it works good.
 
Upvote 0
Top