Prerequisites
...
Load & Show the Ad
Consider a scenario where a button click triggers an Interstitial and, subsequently, the NewActivity
is launched from MainActivity.
...
Code Block | ||
---|---|---|
| ||
#MainActivity.kt->onCreate() val interstitialConfigId = ConfigBuilder.INTERSTITIAL_TEST_R89_CONFIG_ID val activityToShowOver = this var interstitialId = RefineryAdFactory.createInterstitial( interstitialConfigId, activityToShowOver, afterInterstitial = { // Here you could load the next activity or fragment. Basically recover app flow Log.d("Interstitial", "After Interstitial") //Example val newActivityIntent = Intent(this, NewActivity::class.java) startActivity(newActivityIntent) }) |
Show On Button Press
Some events take First some event takes place in you app, such as a button press, tab change or opening a link.
Note |
---|
If the Interstitial hasn’t Loaded yet or failed to load when you call |
Code Block | ||
---|---|---|
| ||
#MainActivity.kt->onCreate() //Example of a button press findViewById<Button>(<YOUR_BUTTON_ID>).setOnClickListener { RefineryAdFactory.show(interstitialId) } |
...
Warning |
---|
This will increase the time it takes to perform the user actionshow the interstitial and then recover app flow. |
Code Block | ||
---|---|---|
| ||
#MainActivity.kt->onCreate() findVIewById<Button>(<YOUR_BUTTON_ID>).setOnclickListener { createInterstitial() } |
...
You can subscribe to these events with the same method but passing a new object as a parameter. Details about this object can be found in the Reference.
OnClose is not present because we have an after interstitial event that is mandatory to pass as a parameter and holds the same functionality that OnClose with special cases.
...