Sure, this is the part of my app where this problem ocurrs:
[lua]local soundID = audio.loadSound (“testSound.wav”)
local _H = display.contentHeight
local _W = display.contentWidth
local SBH = display.topStatusBarContentHeight
local webView = native.newWebView( 0, SBH, _W, _H-SBH)
webView.anchorX = 0
webView.anchorY = 0
webView:request( “this is a web page im using as the interface for the app” ) --basically my app is a wrapper for a mobile web page
local function listener(event)
if event.url == “callto://00000000” then --theres a “callto://” link in the web page–
webView:back( ) --because the webView displays a 404 error with this kind of URL schemes…
system.openURL( “tel:00000000” ) --this is the problematic code
--any code i write here doesnt run when returning to the app (for the first 4-5 times…)
end
end
webView:addEventListener(“urlRequest”,listener)
local function onSystemEvent(event)
if event.type == “aplicationSuspend” then
webview.removeSelf()
audio.play( soundID )
elseif event.type == “aplicationResume” then
audio.play( soundID )
end
end
Runtime:addEventListener( “system”, onSystemEvent )[/lua]
I have my app play a sound each time the app suspends and resumes… (and remove the webView object when the app suspends)
However, when the app suspends the “applicationSuspend” event does not fire at all (it should, as far as i know) because when i return to the app the webView is still there…(native webviews are not supported on the windows version of the simulator, so no console output for me (as far as i know), so i have to run it on the phone and thats the only way i could think of, to be sure if the event actually fires :lol: )
Also, the “applicationResume” event does not fire when returning to the app (that is the main problem, as the app fires the openURL dialing command again as soon as i return to the app)
It is not until i repeat this cycle: (openURL to switch to phone app and dial, switch to my app; and the app switches again to the phone app upon “resuming”) several times (like 4 or 5) that the app finally resumes (and the “applicationResume” event actually fires…)
I have tried with several other ways of acomplishing the same functionality, for example:
[lua]
— inside the listener funtion… instead of system.openURL(“tel:00000000”)
local tm = timer.performWithDelay(2000, phoneCall)
tm.params = {num = “tel:00000000”}
webView.removeSelf() – i’ve tried with and without removing the webView…
–somewhere else in the code…
local function phoneCall(event)
local prms = event.source.params
system.openURL(prms.num)
end[/lua]
However the problem persists