Get url from the webView in android app -


i'm trying current url webview , save editfield using code :

browser = (webview) findviewbyid(r.id.webview);   browser.setonclicklistener(new onclicklistener() {      @override     public void onclick(view v) {         string url = browser.geturl().tostring();          edittext  urltext= (edittext)  findviewbyid (r.id.urltext);          urltext.settext(url);      } }); 

but not working please me out. in advance .

as want url onclick , can listen shouldoverrideurlloading event of webview current url.

webview.setwebviewclient(new webviewclient() {              public boolean shouldoverrideurlloading(webview view, string url){                 webview.loadurl(url);                  // here string url hold 'clicked url'                  return false;              }          }); 

string url of function contains current url.


Comments