java - Android 5 webview native navigation on m.youtube.com is broken by javascript -


i noticed on page http://m.youtube.com method webview.goback() doesn't work after inject javascript. happens on android 5.0+.

i wrote test app contains of webview (code below). steps following:
1. load m.youtube.com webview programmatically.
2. press on video , navigate youtube page.
3. press hardware "back" button, calls webview.goback() method.
expect go m.youtube.com, nothing happens.

can explain why happens (i think because webview's native navigation implemented javascript, , scripts interracting in strange way, can't imagine happens because script empty) , how work around this?

thanks in advance!

public class mainactivity extends actionbaractivity {  private webview  mwebview;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     mwebview = (webview) findviewbyid(r.id.webview);     mwebview.setwebviewclient(new myclient());     mwebview.getsettings().setjavascriptenabled(true);     mwebview.loadurl("http://youtube.com"); }  public void onbackpressed() {     if (mwebview.cangoback()) {         mwebview.goback();     } else {         finish();     } }  private class myclient extends webviewclient {      @override     public void onpagefinished(webview view, string url) {         view.loadurl("javascript:;");     } } } 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -