A Fuse Powered Company

Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Phone Calls from native.webView
Started by casasgranada.es Feb 11 2014 08:32 PM

2 replies to this topic
phone calls
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

casasgranada.es

[GLOBAL: userInfoPane.html]
casasgranada.es
  • Starter
  • Pip
  • 4 posts
  • Newbie

Hello.

Im finishing an app based in a mobile website.

 

In iOS everything fine, but in Android it can not make calls based in tel:XXXXXX html code.

 

I have given all permisions to Android in builds.settings:

 

    android =
    {   
        usesPermissions =
        {
            "android.permission.INTERNET",
            "android.permission.ACCESS_WIFI_STATE",
            -- Permission to retrieve current location from the GPS.
            "android.permission.ACCESS_FINE_LOCATION",

            -- Permission to retrieve current location from WiFi or cellular service.
            "android.permission.ACCESS_COARSE_LOCATION",
            "android.permission.ACCESS_NETWORK_STATE",
            -- Permiso para usar el protocolo de llamadas
            "android.permission.CALL_PHONE",
            "android.permission.CALL_PRIVILEGED",
            "android.permission.PROCESS_OUTGOING_CALLS",
            "android.permission.READ_PHONE_STATE",
        }

    }

        
}

 

The error its giving is: "Web site unvaible", any idea how to implement this function rightly.

 

Thanks



[TOPIC: post.html]
#2

Joshua Quick

[GLOBAL: userInfoPane.html]
Joshua Quick
  • Corona Staff
  • 2,688 posts
  • Jedi

Unlike iOS, Android's native WebViews do not automatically handle "mailto://", "tel://", or any custom app URL schemes for that matter.  Android's native WebView blindly assumes that all links lead to a web page.  That's just the way Google made it.  So, instead Google expects you to override the WebView's URL request and handle it for yourself.  You can do this in Corona by adding a listener to the WebView as shown here...

   http://docs.coronalabs.com/api/library/native/newWebView.html#TOC

 

Once your listener receives a "tel://" URL scheme, you can then override it and launch the phone app via Corona's system.openURL() which does support this telephone scheme.  Also note that I think the WebView may still display a page not found even when you attempt to load it.  This is especially true if that URL is invoked via JavaScript, because Android's native WebView does not give the native developer a chance to override it... only detect that it is currently loading it.  So, you may have to call the WebView's back() function.

 

That said, I wish there was a simpler way to do this, but this is where the native WebView handling between iOS and Android is quite different.  In fact, it might be simpler to avoid using a WebView for something like this just to avoid the hassle.



[TOPIC: post.html]
#3

casasgranada.es

[GLOBAL: userInfoPane.html]
casasgranada.es
  • Starter
  • Pip
  • 4 posts
  • Newbie

Hello, thanks for the reply.

 

I couldn't implement the tel:// url scheme, can you help a bit more in this topic please?

I tried to overwite the url request but I think I dont know right how to.

 

Thanks




[topic_controls]
[/topic_controls]



Also tagged with one or more of these keywords: phone, calls