Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7604091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:49:14+00:00 2026-05-30T23:49:14+00:00

package com.example.t2noob; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.net.Uri;

  • 0
package com.example.t2noob;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.Toast;

public class Activity extends Activity
{   
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;
    }



  WebView mWebView;




  public void onCreate(Bundle paramBundle)
  {



      super.onCreate(paramBundle);
      requestWindowFeature(1);
      getWindow().setFlags(1024, 1024);
      setContentView(2130903040);
      final Button button = (Button) findViewById(R.id.Home);//BUTTONS ON TOP OF WEBVIEW. HOME
      button.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
            mWebView.loadUrl("test.com");
          }
      });
      final Button button1 = (Button) findViewById(R.id.Back);//BUTTONS ON TOP OF WEBVIEW. BACK
      button1.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
            mWebView.goBack();
          }
          });

      this.mWebView = ((WebView)findViewById(2131034112));
      this.mWebView.getSettings().setJavaScriptEnabled(true);
      this.mWebView.setWebViewClient(new WebViewClient());
      this.mWebView.getSettings().setJavaScriptEnabled(true);
      this.mWebView.setVerticalScrollBarEnabled(true);
      this.mWebView.setHorizontalScrollBarEnabled(true);
      this.mWebView.loadUrl("test.com");
      this.mWebView.getSettings().setLoadWithOverviewMode(true);

       }


      public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)//LETS USER PUSH BACK BUTTON ON PHONE TO GO BACK A PAGE IN WEBVIEW.
      {
        boolean bool;
        if ((paramInt != 4) || (!this.mWebView.canGoBack()))
        {
     bool = super.onKeyDown(paramInt, paramKeyEvent);
 }
 else
 {
   this.mWebView.goBack();
   bool = true;
 }
 return bool;
}   

}

So i have the above source code the function shoudOverrideUrlLoading
should catch both the web links to open them in the webview if I didn’t misread
and open phone numbers with the android dialer.
with the above code i can get links to open in the webview but it wont open the numbers in the dialer.
If i add this code to the program.

private static final WebViewClient Webview = null;
this.mWebView.setWebViewClient(Webview);

I can get the dialer to open but then the web links wont open in the webview but will actually open in the default browser.
So i would like some help in how to get it to open phone numbers in the dialer and web links in the webview and not just have either or.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T23:49:16+00:00Added an answer on May 30, 2026 at 11:49 pm

    Use this

    private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
      if(url.contains("tel:"))
      {
       //make the substring with the telephone number, and invoke intent for dialer
      }
     else
       view.loadUrl(url);
       return true;
    }
    

    }

    And set the web view client as

    this.mWebView.setWebViewClient(new HelloWebViewClient());
    

    This will make sure the links are opened in the same web view, and not the browser.
    Note : Remove all other uses of setWebViewClient()

    Edited : This will solve!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My code: package com.example.linkingpage; import android.app.Activity; import android.app.AlertDialog; import android.app.Dialog; import android.content.DialogInterface; import android.content.Intent;
Here is My Whole Code....... BroadcastExample.java package com.example.broadcast; > import android.app.Activity; import > android.content.Context;
package com.example.Calc; import android.R.string; import android.app.ListActivity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter;
This is my code: package com.example.testcode; import android.app.ListFragment; import android.app.LoaderManager; import android.content.CursorLoader; import android.content.Loader;
package com.example.android.home; import android.app.Activity; import android.os.Bundle; import android.widget.*; import android.view.*; public class HomeActivity extends
package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.Button; import android.view.View; import android.view.View.OnClickListener; //Create an
Main Activity Code. BroadcastExample.java package com.example.broadcast; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class
package com.example.helloandroid; import android.app.Activity; import android.os.Bundle; import android.widget.TextView; public class HelloAndroid extends Activity {
1st activity package com.example.parserss; import java.net.URL; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import org.xml.sax.InputSource; import org.xml.sax.XMLReader;
package com.example.helloandroid; import java.util.ArrayList; import java.util.Arrays; import android.app.TabActivity; import android.os.Bundle; import android.view.Window; import android.widget.ArrayAdapter;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.