Click here to Skip to main content
15,789,776 members
Please Sign up or sign in to vote.
0.00/5 (No votes)

With the code of of android studio I can get my URL loaded correctly, but, I get "ERR_UNKNOWN_URL_SCHEME" when trying to tap on links that starts with tg: (Telegram).

Anyone can help me to solve this issue, please? Unfortunately, I am a complete beginner in android java code. Please guide me where to put the code to resolve the tg: telegram link issue.
package com.tesco.webview;


import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MainActivity extends AppCompatActivity {
    private WebView mywebView;
    protected void onCreate(Bundle savedInstanceState) {
        mywebView=(WebView) findViewById(;
        mywebView.setWebViewClient(new WebViewClient());
        WebSettings webSettings=mywebView.getSettings();
    public class mywebClient extends WebViewClient{
        public void onPageStarted(WebView view, String url, Bitmap favicon){
        public boolean shouldOverrideUrlLoading(WebView view,String url){
            return true;

    public void onBackPressed(){
        if(mywebView.canGoBack()) {

What I have tried:

I'm a beginner in android development. So I have tried other solutions but they dont worked that's why I'm asking questions here.
Richard MacCutchan 13-Mar-21 4:49am    
The prefix tg: is not valid in a webrequest. Where are these links that you are trying to access?
sagarjkhatri 13-Mar-21 5:36am    
It link which is a telegram link inside the website(mywebView.loadUrl(""); that I'm trying to make a webview app.
Richard MacCutchan 13-Mar-21 5:43am    
Sorry, I have no idea what that means. It does not look like a valid URL.
sagarjkhatri 13-Mar-21 5:47am    
Sir is the link I'm trying to access which is a telegram link.
Richard MacCutchan 13-Mar-21 5:49am    
That is not a valid URL, it needs the http:// or https:// prefix.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900