weird behaviour with system.openURL() <when dialing a phone number>

Hello, i am pretty new to coronaSDK so i’m not sure about this…

I don’t know if this is a bug, but im using system.openURL() on my app to dial a phone number (ex. “tel:1234567890”)… However, when i stop the phone call and hold the home button to show active apps and switch to my app, inmediately my app sends me again to the phone app and dials again… this happens several times before i can “resume” using the app; even if i wait a moment before switching back to my app

Incidentally, the “applicationSuspend” system event does not even fire when system.openURL() is called and the app switches to the phone app to dial; and i think, (unless i am mistaken?), that it is supposed to be fired?

Also, the “aplicationOpen” event doesn’t fire either; which, acording to corona docs, should fire, right?

The “aplicationResume” does fire, though

Also, i´ve tried a ‘workaround’: i made a TinyURL from the “tel:” scheme and used thar url with system.openURL() so as to open the web browser, and then, the browser app is the one to call the “tel:” scheme… However, the same problem occurs…sort of…

Curiously, this behaviour does not present itself when opening a normal web page directly, through system.openURL()…

Any help would be apreciated.  :slight_smile:

Can you post the code you are using?

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

Hi @jorch.rl,

The first thing I notice is a spelling error in your “onSystemEvent()” function (two errors actually). You have:

[lua]

“aplicationSuspend”

– should be “applicationSuspend”

“aplicationResume”

– should be “applicationResume”

[/lua]

Please fix those first and report back the behavior.

Best regards,

Brent

Hi Brent!. thanks for pointing that out!  

Effectively it was a typo on my part…

However the problem is still there (i only added the onSystemEvent() function in the first place, to monitor if the app was actually resuming, instead of just immediately jumping back to the phone app…)

The “applicationSuspend” event still does not fire, though. And the “applicationResume” fires only on the third or fourth time the app resumes (when it doesn’t jump back to the phone app)

Can we get you to file a bug report?  The bug report will be a functional sample that demonstrates the problem.  Include any assets needed including the HTML page you are trying to open.  Make sure to include your build.settings and config.lua.  Put all of this in a .zip file (no .rar files) and use the “Report a bug” link at the top of the page.  You will get an email with a Case ID # in the subject.  Post that here when you get it. 

Rob

Hello Rob, i have submitted the bug report as you instructed me. the case id # i received is: 40086 

Also, i apologize for my late response, i was out of town for the whole past week with no internet…

I made a new app with a new (and local) web page just to make sure the problem wasn’t happening because of the web page i was requesting (i think it wasn’t, because the problem is still there)

Also, the problem happens in my phone (android 4) and a friend’s (android 2). (so i guess the problem isn’t in the phone either?) i have no way to test in other devices.

Thank you very much for your attention

Can you post the code you are using?

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

Hi @jorch.rl,

The first thing I notice is a spelling error in your “onSystemEvent()” function (two errors actually). You have:

[lua]

“aplicationSuspend”

– should be “applicationSuspend”

“aplicationResume”

– should be “applicationResume”

[/lua]

Please fix those first and report back the behavior.

Best regards,

Brent

Hi Brent!. thanks for pointing that out!  

Effectively it was a typo on my part…

However the problem is still there (i only added the onSystemEvent() function in the first place, to monitor if the app was actually resuming, instead of just immediately jumping back to the phone app…)

The “applicationSuspend” event still does not fire, though. And the “applicationResume” fires only on the third or fourth time the app resumes (when it doesn’t jump back to the phone app)

Can we get you to file a bug report?  The bug report will be a functional sample that demonstrates the problem.  Include any assets needed including the HTML page you are trying to open.  Make sure to include your build.settings and config.lua.  Put all of this in a .zip file (no .rar files) and use the “Report a bug” link at the top of the page.  You will get an email with a Case ID # in the subject.  Post that here when you get it. 

Rob

Hello Rob, i have submitted the bug report as you instructed me. the case id # i received is: 40086 

Also, i apologize for my late response, i was out of town for the whole past week with no internet…

I made a new app with a new (and local) web page just to make sure the problem wasn’t happening because of the web page i was requesting (i think it wasn’t, because the problem is still there)

Also, the problem happens in my phone (android 4) and a friend’s (android 2). (so i guess the problem isn’t in the phone either?) i have no way to test in other devices.

Thank you very much for your attention