Are you the android developer or user? And you are facing the issue err_unknown_url_scheme? Follow the methods given below to solve the issue.
Contents
What is err_unknown_url_scheme?
Err_unknown_url_scheme is an error usually encountered when an application or website which you download attempts to collect some information from the device. Shortly, the WebView URL project cannot be authenticated.
The error screen can be stopped by some lines of code.
When err_unknown_url_scheme occur?
- When calling a phone number option from Android.
- While trying to open a redirected URL.
- On click a link it throws this error in spite of opening new page.
- This issue may occur with mailto: tel: sms: and geo: links inside an iframe.
- When trying to use OAuth with Chrome custom tab.
How the error screen looks like?
How to Fix err_unknown_url_scheme error?
METHOD:1
Add target=”_blank” in your URL href code.
Example: <a href=”mailto:hai@email.com” target=”_blank”>link text which need to added</a> (or) <a href=“tel:123-456-7890” target=”_blank”>Call Techmazza Admin</a>
METHOD:2
If you are a developer or programmer, then follow code snippet to fix this issue.
Note: Check if you have specified a http or https prefix in the URL. Preferred to url as prefix: ftp: https: sftp: ‘scheme’
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if( url.startsWith(“http:”) || url.startsWith(“https:”) ) {
return false;
}
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
return true;
}else if (url.startsWith(WebView.SCHEME_TEL) ||
url.startsWith(“sms:”) ||
url.startsWith(WebView.SCHEME_MAILTO) ||
url.startsWith(WebView.SCHEME_GEO) ||
url.startsWith(“maps:”))
{
try {
Log.d(LOG_TAG, “loading in external app”);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
} catch (android.content.ActivityNotFoundException e) {
LOG.e(LOG_TAG, “Error opening external app ” + url + “: ” + e.toString());
}
}
Method 3:
If the error occurred in Android sceen, then add the below code.
Note: Add to AndroidManifest.xml
<uses-permission android:name=”android.permission.CALL_PHONE”/>
The code allows you to give permission to access the phone number.
METHOD: 4
If you want to disable the error in Android screen then the developer add the following snippet.
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
public class MainActivity extends AppCompatActivity {
String url = "http://www.google.com";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webactivity);
final WebView webview = (WebView) findViewById(R.id.web1);
webview.loadUrl(url);
webview.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
if (url.startsWith("http") || url.startsWith("https")) {
return true;
}else {
webview.stopLoading();
webview.goBack();
Toast.makeText(MainActivity.this, "Unknown Link, unable to handle", Toast.LENGTH_SHORT).show();
}
return false;
}});}}
Final Words:
The error occurs both in Chrome or Android but the issue has to be fixed from developer end. And has to be tested by the tester. Nothing have to go with user end.