android - why does my shouldOverrideLoading method never get called? -


i trying show toast on shouldoverrideloading, however, never gets called. code huge stripped down way smaller code still can't find mistake making. here code:

public class mainactivity extends activity {  private webview webview; private edittext urledittext; private progressbar progress;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      urledittext = (edittext) findviewbyid(r.id.urlfield);     webview = (webview) findviewbyid(r.id.webview);     webview.setwebchromeclient(new mywebviewclient());     cookiemanager.getinstance().setacceptcookie(true);// enable cookies     webview.getsettings().setjavascriptenabled(true);// enable java script     webview.setwebviewclient(new viewclient());      webview.getsettings().setpluginstate(pluginstate.on);// enable flash      webview.getsettings().setloadsimagesautomatically(true);     webview.setwebviewclient(new webviewclient() {// ************************************         // on page load , finished         @override         public void onpagestarted(webview view, string url, bitmap favicon) {             inputmethodmanager imm = (inputmethodmanager) getsystemservice(// hide_keyboard             context.input_method_service);             imm.hidesoftinputfromwindow(urledittext.getwindowtoken(), 0);             super.onpagestarted(view, url, favicon);         }          @override         public void onpagefinished(webview view, string url) {         }          // **//         @override         public void onreceivederror(webview view, int errorcode,                 string description, string failingurl) {             toast.maketext(getbasecontext(), "pull down refresh",                     toast.length_long).show();             view.loadurl("about:blank");             super.onreceivederror(view, errorcode, description, failingurl);         }     });     progress = (progressbar) findviewbyid(r.id.progressbar);     progress.setmax(100);     // use done/search button in keyboard go button     urledittext = (edittext) findviewbyid(r.id.urlfield);     urledittext.setoneditoractionlistener(new oneditoractionlistener() {         public boolean oneditoraction(textview arg0, int arg1, keyevent arg2) {             customsearch();             return false;         }     }); }  private class mywebviewclient extends webchromeclient {     @override     public void onprogresschanged(webview view, int newprogress) {         mainactivity.this.setvalue(newprogress);         super.onprogresschanged(view, newprogress);     } }  public void setvalue(int progress) {     this.progress.setprogress(progress); }  class viewclient extends webviewclient {     @override     public boolean shouldoverrideurlloading(webview webview, string url) {         toast.maketext(getbasecontext(), "page started", toast.length_long)                 .show();         webview.loadurl(url);         return true;     } }  public void customsearch() {     // go button searching worldwide     urledittext = (edittext) findviewbyid(r.id.urlfield);     string url = urledittext.gettext().tostring();     webview.loadurl(url); }  } 

the problem here:

webview.setwebviewclient(new viewclient()); webview.getsettings().setpluginstate(pluginstate.on);// enable flash webview.getsettings().setloadsimagesautomatically(true); webview.setwebviewclient(new webviewclient() {     // ... } 

first, pass viewclient instance setwebviewclient(), , then, without ever using it, overwrite simple webviewclient instance, not have overriden shouldoverrideloading method.


Comments

Popular posts from this blog

wordpress - (T_ENDFOREACH) php error -

Export Excel workseet into txt file using vba - (text and numbers with formulas) -

Using django-mptt to get only the categories that have items -