0

I need to take url after loading a web page in my web view to check condition and if I use onPageFinished() method, then where to use.

Manjunath
  • 52
  • 1
  • 10

1 Answers1

0

Just set a webview client and override onpagefinished as shown below

 public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        WebView webView = findViewById(R.id.webview);
        webView.loadUrl("http://www.google.com");
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                Toast.makeText(getApplicationContext(), url,Toast.LENGTH_LONG).show();
            }
        });
    }
}

inside onpagefinished you have the url

hushed_voice
  • 3,161
  • 3
  • 34
  • 66