Fix ERR_UNKNOWN_URL_SCHEME on Android WebView for tel

I am building a hybrid mobile app with Visual Studio Tools for Apache Cordova that is able to make phone calls, send text message or emails, view a location on a map, etc. These are all handled with external applications (for instance use Gmail to send an email or Maps to pinpoint a location). They are placed in an anchor tag in HTML, such as <a href="tel:12345678">, <a href="sms:12345678">, <a href="mailto:name@domain.com"> or <a href="geo:...">. These work fine except that when you execute one of these actions and the system opens another app you see for a short time a webview with an error: “Web page not available”. Then the external app opens, you take the action and then go back to the app. At that point you again see this webview with the error as shown below.
ERR_UNKNOWN_URL_SCHEME when sending a text message
ERR_UNKNOWN_URL_SCHEME when sending a text message

solution is:

@Override
public boolean shouldOverrideUrlLoading(WebView webview, String url)
{
if (url.startsWith("tel:") || url.startsWith("sms:") || url.startsWith("smsto:") || url.startsWith("mms:") || url.startsWith("mmsto:"))
{
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse(url));
startActivity
(intent);
return true;
}
return false;
}

Comments

Popular posts from this blog

App Store Connect ITMS-90078: Missing Push Notification Entitlement - Your app appears to register with the Apple Push Notification service, but the app signature's entitlements do not include the "aps-environment"

Facts about bb ki vines bhuvan bam

RGPV CSE 8th Semester Soft computing Notes and Lectures