Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the current page url from the web view in android

Using webview.loadUrl(url) method I open an url. If I click any Button on the view it directs to another page. Now I want to get the url of the directed page. how can I get it?

I also want the content that is displayed on the webview. How to get the content of the WebView ?

like image 983
sam Avatar asked May 23 '14 11:05

sam


People also ask

How do I get the current URL in react native WebView?

To get current URL with React Native webview, we can set the onNavigationStateChange prop to a function that listens for navigation events in the webview. to set onNavigationStateChange to the onNavigationStateChange function. In it, we log webViewState. url which has the URL of the current page in the webview.

How do I view web pages on Android?

String url = "http://www.example.com"; Intent i = new Intent(Intent. ACTION_VIEW); i. setData(Uri. parse(url)); startActivity(i);


2 Answers

String webUrl = webView.getUrl();
like image 170
Vinayak Bevinakatti Avatar answered Oct 21 '22 19:10

Vinayak Bevinakatti


please see my answer may it will help you...!!!!

WebView webview = new WebView(context);
webview.setWebViewClient(new WebViewClient()
        {
            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);

                Log.d("WebView", "your current url when webpage loading.." + url);
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                Log.d("WebView", "your current url when webpage loading.. finish" + url);
                super.onPageFinished(view, url);
            }

            @Override
            public void onLoadResource(WebView view, String url) {
                // TODO Auto-generated method stub
                super.onLoadResource(view, url);
            }
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                System.out.println("when you click on any interlink on webview that time you got url :-" + url);
                return super.shouldOverrideUrlLoading(view, url);
            }
        });
like image 34
V.P. Avatar answered Oct 21 '22 19:10

V.P.