Android Question Wait until the ad is shown in AdMob

angel_

Well-Known Member
Licensed User
Longtime User
In AdMob when I have the ad (interstitial) ready to show it doesn't always show on the screen, would it be possible to wait a while to show that ad before continuing? Would this code be valid?

B4X:
'https://www.b4x.com/android/forum/threads/b4x-wait-for-the-first-task-to-complete.160023/
If iAd.Ready Then
    iAd.Show
    Dim status(1) As String
    WaitForSuccess(status)
    Do While status(0) = ""
        Sleep(50)
    Loop
Else
    LogColor("no ad is available", xui.Color_Red)
End If
iAd.LoadAd
        
Private Sub WaitForSuccess (Status() As String)
    TimeOut(300, Status)
    Wait For iAd_AdOpened
    Status(0) = "success"
End Sub

'https://www.b4x.com/android/forum/posts/660853
Sub TimeOut(Duration As Int, Status() As String)
    Sleep(Duration)
    Status(0) = "end time"
End Sub
 
Top