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

  • Home
  • SEARCH
  • 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 9179699
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:51:54+00:00 2026-06-17T17:51:54+00:00

I was wondering if there exits another effective way to get the URL that

  • 0

I was wondering if there exits another effective way to get the URL that will load up on the WebView. My current code gives the current Url and not the one that will be loaded.

For example if my WebView load this: http://stackoverflow.com

After loading If I click on Questions, I would not get this url http://stackoverflow.com/questions, for some reason I would get http://stackoverflow.com

So my question is how would you get the url that will be loading on a WebView?

This is my code, please help!

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;

public class MainActivity extends Activity {

    // Declaring
    WebView browser;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Initializing
        browser = (WebView) findViewById(R.id.webView1);

        browser.getSettings().setJavaScriptEnabled(true);
        browser.getSettings().setLoadWithOverviewMode(true);
        browser.getSettings().setUseWideViewPort(true);
        browser.getSettings().setBuiltInZoomControls(true);

        // Loading
        browser.loadUrl("http://stackoverflow.com");


        browser.setWebViewClient(new WebViewClient() {
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    view.loadUrl(url);

                return true;
            }

            public void onLoadResource(WebView view, String url) {

                //here I get the Url, but its not accurate. Sometimes it works, sometiems it doesn't 
                    Toast.makeText(getApplicationContext(), browser.getUrl(),
                            Toast.LENGTH_SHORT).show(); 
            }


        });

    }

}
  • 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-17T17:51:55+00:00Added an answer on June 17, 2026 at 5:51 pm

    Try to get url from this function :

    EDIT:

            browser.loadUrl("http://stackoverflow.com");
    
            browser.setWebViewClient(new WebViewClient() {
                public boolean shouldOverrideUrlLoading(WebView view, String url) {
                    Toast.makeText(getApplicationContext(), url, Toast.LENGTH_SHORT).show(); 
                    Log.v("TEST", url);
                    if(url.equals("http://stackoverflow.com/questions")){
                        Toast.makeText(getApplicationContext(), "SKIP", Toast.LENGTH_SHORT).show();
                    }
                    else{
                       view.loadUrl(url); 
                    }                 
                    return true;
                }
            });
    

    Reference :

    shouldOverrideUrlLoading

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

Sidebar

Related Questions

Wondering if there is any way to get the lambda expressions that result from
Wondering if there is a good way to generate temporary URLs that expire in
just wondering if there is a way to reduce the amount of code needed
I'm just wondering is there a way to make the 'null' that is outputted
I was wondering if there exists any open source frameworks that will help me
I was wondering if there exists any way to set a constraint on the
I'm working with a DOMDocument , and I'm wondering if there exists some way
Wondering if there is any tool that can help me to detect a pronoun's
I was wondering if there is a way to create a MySQL table for
I was wondering if theres a way to make a batch file that uses

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.