java - Getting web page title from setWebViewClient? -


I am using webview in my Android app. I want to get the title of the current page shown in the webview. I'm using the following code to do this

  webView.setWebViewClient (new WebViewClient () {public void onPageFinished (WebView view, string url) {TextView t = (TextView) findViewById ( R.id. Title); t.setText (view.getTitle ());}}   

This code always works but not always. Sometimes this title does not show. Sometimes this shows the title of the previous page WebChromeClient will give you the web page. I WebViewClient

  webview.loadUrl ("https: // Www.google.co.in/ "); webview.setWebCh RomeClient (New WebChromeClient () {@Override Residual on Public Zero (webview view, string sTitle) {super.onReceivedTitle (see, sTitle); if (sTitle! = Null & gt; Title.length ()> 0) { Title.setText (sTitle);} and {title.setText ("web page");}}});    

Comments