Android Question AppOpenAd and B4XPages

asales

Expert
Licensed User
Longtime User
I want to show the AppOpenAd everytime that user open the app.

I create an splashscreen class to wait to load the ad and show it.
I call the splash class in B4XPage_Foreground:
B4X:
Sub B4XPage_Foreground
    Ads.Initialize
    CheckConsentAndAddAds
    Root.LoadLayout("splash")
    Splash.Initialize
    Splash.Show(pContent)
End Sub

After the splash finish, the class call the sub:
B4X:
CallSub(B4XPages.MainPage,"MainScreen")

To show the main screen and start the AppOpenAd
B4X:
Sub MainScreen
    Root.LoadLayout("MainPage")
(...)
    Ads.ShowOpenAdIfAvailable
End Sub

When the AppOpenAd is show, it call the sub B4XPage_Background and when it closed it call the B4XPage_Foreground with the splash, in a infinity loop.

How can I solved it: how the splash and ad everytime that the user open the app and when the ad is closed, it show the main screen?

Thanks in advance for any tip.
 
Top