0 0CrimsonScythe0 Member Licensed User Longtime User Nov 15, 2014 #1 I want to display an ad when the user presses the back button for which I am using the following code: Code: Copy Sub Activity_KeyPress(KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then ad2.loadAd() End If End Sub The problem is that the app closes before the ad can be displayed properly. Is there a way to let the app exit only when the ad gets displayed and is cancelled?
I want to display an ad when the user presses the back button for which I am using the following code: Code: Copy Sub Activity_KeyPress(KeyCode As Int) As Boolean If KeyCode = KeyCodes.KEYCODE_BACK Then ad2.loadAd() End If End Sub The problem is that the app closes before the ad can be displayed properly. Is there a way to let the app exit only when the ad gets displayed and is cancelled?
RandomCoder Well-Known Member Licensed User Longtime User Nov 15, 2014 #2 After loading your ad, start a timer and consume the key press with 'return true'. You can then exit the app within the timer tick event. A 4 second delay will probably be long enough. Upvote 0
After loading your ad, start a timer and consume the key press with 'return true'. You can then exit the app within the timer tick event. A 4 second delay will probably be long enough.
0 0CrimsonScythe0 Member Licensed User Longtime User Nov 16, 2014 #3 Exactly what I needed ,thanks! Upvote 0