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 8027131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:43:31+00:00 2026-06-04T23:43:31+00:00

a lot of Android developer implement their own webview. Although a lot of questions

  • 0

a lot of Android developer implement their own webview.
Although a lot of questions related to this topic are discussed on stackoverflow, here is probably a cause of this lack of clarity.

To open links within your WebView, android developer define their own webview.

  • According to http://developer.android.com/guide/webapps/webview.html returning false in shouldOverrideUrlLoading should be used, to open the url in the current Webview.
    (“current” means presumably created or used lately?)

  • According to http://developer.android.com/resources/tutorials/views/hello-webview.html and various blogs:

    public boolean shouldOverrideUrlLoading(WebView view, String url) {
       view.loadUrl(url);
       return true;
    }
    

    true must me returned.

Is there a mistake in one of the developer sites? It there difference between API level?
What is the cleanest and best use of shouldOverrideUrlLoading?

An answer would help our team and a lot of other developers working with android webviews.Thanks.

  • 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-06-04T23:43:32+00:00Added an answer on June 4, 2026 at 11:43 pm

    In case you decide to implement WebViewClient:

    webView.setWebViewClient(new WebViewClient()
    {
      @Override
      public boolean shouldOverrideUrlLoading(WebView view, String url)
      {
        // My own condition to decide if I should skip URL loading
        boolean avoidURLLoading = ...
    
        if (avoidURLLoading)
        {
          // Ask the WebView to avoid loading the URL,
          // I want to manage this case on my own.
          return true;
        }
        else
        {
          // Let the WebView load the URL 
          return false;
        }
      };
    });
    

    If you don’t implement WebViewClient, every time you’ll ask the WebView to load an URL with the loadUrl method, it will ask the Activity Manager to find a proper app to load the URL (typically a web browser installed in the device).

    The default implementation of shouldOverrideUrlLoading in WebViewClient is

    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
      return false;
    }
    

    So if you just write something like this

    webView.setWebViewClient(new WebViewClient());
    

    the URL will load inside your own WebView and not in an external web browser.

    You’ll typically return true in shouldOverrideUrlLoading when you want to modify the URL and then load the new one with another loadUrl call or when you just want to avoid loading the URL and handle the request in a different way.

    The behavior in your example

    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
      view.loadUrl(url);
      return true;
    }
    

    is equivalent to

    public boolean shouldOverrideUrlLoading(WebView view, String url)
    {
      return false;
    }
    

    because you’re telling the WebView to avoid handling the URL loading (return true), but you’re also making another request with view.loadUrl(url) so in fact you end up loading the URL.

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

Sidebar

Related Questions

I have researched a lot about creating my own app for android with a
fairly new Android developer here. I've come across a strange problem that I'm not
I read a lot about this problem on Stackoverflow but not of the Helps
I know there is a lot of stuff even on stackoverflow about this theme/problem
I read the android developer guide. I got idea about android applcations a lot.
i have an android project which has a lot of classes I've built. i
I created an android app to display a lot of images some of them
I'm pretty new to Android dev and still working out a lot of things.
I've read a lot about building UI that supports multiple screen resolutions on android.
I consider myself an Android developer, after having created four apps and learned a

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.