-2

I have a telephone link on my webview app: tel:062123658 but when i click on it.. i get webpage not found.

This is my code:

public class FullscreenActivity extends Activity {

    private WebView webView;

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fullscreen);

        webView = (WebView) findViewById(R.id.webView);
        webView.setWebViewClient(new myWebClient());
        webView.loadUrl("http://www.mywebsite.nl/");
        webView.setVerticalScrollBarEnabled(false);
    }

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.startsWith("tel:")) { 
                Intent intent = new Intent(Intent.ACTION_DIAL,
                        Uri.parse(url)); 
                startActivity(intent); 
        }else if(url.startsWith("http:") || url.startsWith("https:")) {
            view.loadUrl(url);
        }
        return true;
    }

How can i fix this?

Thanx.

Marv
  • 33
  • 11

1 Answers1

0

I'm assuming the "0621" is a Heidelberg prefix, thus as a matter of practice, consider prefixing with the +49 621 ...

Try this:

Intent intent = new Intent(Intent.ACTION_CALL);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
intent.setData(Uri.parse(url));
startActivity(intent);
Di Vero Labs
  • 344
  • 1
  • 4