Closing interstitial causing app to restart

Using admob 2… when I load an interstitial… it loads its own close button… If I tap that close button it is causing my app to restart… I do not know why… Anyone have any advice?

After some more research. I think maybe the close button on the interstitial ad fires a key event? And Im not listening for it… as I dont know what it is… (if thats what it is doing.) I also noticed that my back key does not work when the interstitial ad is up… It does the same thing as the interstitial ads close btn… restarts the app. Here is the code im using for the back key event. 
 

local function onKeyEvent( event )
 
   local phase = event.phase
   local keyName = event.keyName
 
if ( “back” == keyName and phase == “down” ) then
 
if menuActive == false then
Runtime:removeEventListener(“touch”, touchScreen)
composer.gotoScene(“mainMenu”)
end
 
if menuActive == true then
menuActive = false
if gameTimer then timer.resume(gameTimer) end
for i = popUpGroup.numChildren,1,-1 do
local child = popUpGroup[i]
child.parent:remove( child )
child = nil
end
if popUp then popUp = nil end
if closeBtn then closeBtn = nil end
highScoreText.alpha = 0
currentScoreText.alpha = 0
timerStash.newTimer = timer.performWithDelay(100, function() gameActive = true end, 1)
ads.hide()
end
 
tutorial.cleanTutorial()
 
for i = tutorialTipGroup.numChildren,1,-1 do
local child = tutorialTipGroup[i]
child.parent:remove( child )
child = nil
end
if bgOverLay then bgOverLay:removeEventListener(“touch”, removeMe) end
 
return true
end
return false
end

Hi @havochare4,

The app restarting sounds like an error/crash or something, not a result of the interstitial ad or a key event. Can you gather an error console output by following the “Debugging” section of this guide, and post the results?

http://docs.coronalabs.com/guide/distribution/androidBuild/index.html#debugging

Thanks,

Brent

Yeah I can do that. What command should I issue to adb? Ive been using this… adb logcat Corona:v *:s 

Here’s the deal… Android has “activities” which run.  When you do:

adb logcat Corona:v *:s

You are in effect only getting the messages generated by Corona SDK.  Normally this is fine, but Corona SDK uses other activities (depending on what you’ve asked it to do)l For instance if you use Facebook, then the Facebook app will handle the work.  Trying to so AdMob or Google IAP v3?  Well you’re using the Google Play app to do the work.  Since you may not know what activity is calling the problem.

If you want to see all messages, simply run:

adb logcat

Rob

Here is the result of adb logcat. I made it error twice… As in… the interstitial was loaded two seperate times… which resulted in the app restarting two times upon touching the ads close button. 

After some more research. I think maybe the close button on the interstitial ad fires a key event? And Im not listening for it… as I dont know what it is… (if thats what it is doing.) I also noticed that my back key does not work when the interstitial ad is up… It does the same thing as the interstitial ads close btn… restarts the app. Here is the code im using for the back key event. 
 

local function onKeyEvent( event )
 
   local phase = event.phase
   local keyName = event.keyName
 
if ( “back” == keyName and phase == “down” ) then
 
if menuActive == false then
Runtime:removeEventListener(“touch”, touchScreen)
composer.gotoScene(“mainMenu”)
end
 
if menuActive == true then
menuActive = false
if gameTimer then timer.resume(gameTimer) end
for i = popUpGroup.numChildren,1,-1 do
local child = popUpGroup[i]
child.parent:remove( child )
child = nil
end
if popUp then popUp = nil end
if closeBtn then closeBtn = nil end
highScoreText.alpha = 0
currentScoreText.alpha = 0
timerStash.newTimer = timer.performWithDelay(100, function() gameActive = true end, 1)
ads.hide()
end
 
tutorial.cleanTutorial()
 
for i = tutorialTipGroup.numChildren,1,-1 do
local child = tutorialTipGroup[i]
child.parent:remove( child )
child = nil
end
if bgOverLay then bgOverLay:removeEventListener(“touch”, removeMe) end
 
return true
end
return false
end

Hi @havochare4,

The app restarting sounds like an error/crash or something, not a result of the interstitial ad or a key event. Can you gather an error console output by following the “Debugging” section of this guide, and post the results?

http://docs.coronalabs.com/guide/distribution/androidBuild/index.html#debugging

Thanks,

Brent

Yeah I can do that. What command should I issue to adb? Ive been using this… adb logcat Corona:v *:s 

Here’s the deal… Android has “activities” which run.  When you do:

adb logcat Corona:v *:s

You are in effect only getting the messages generated by Corona SDK.  Normally this is fine, but Corona SDK uses other activities (depending on what you’ve asked it to do)l For instance if you use Facebook, then the Facebook app will handle the work.  Trying to so AdMob or Google IAP v3?  Well you’re using the Google Play app to do the work.  Since you may not know what activity is calling the problem.

If you want to see all messages, simply run:

adb logcat

Rob

Here is the result of adb logcat. I made it error twice… As in… the interstitial was loaded two seperate times… which resulted in the app restarting two times upon touching the ads close button.