android - How to handle a webview confirm dialog? -


i'm displaying webpage in webview , on webpage, there button. when click button, confirmation dialog supposed popup, doesn't show in webview. popup if go same webpage in android browser. know how handle popup dialogs coming webpage inside webview?

ok, found answer , here is!

in order handle popup confirmation coming webpage in webview, need override onjsconfirm method in webchromeclient display popup android alert dialog. here code so.

final context myapp = this;  final class mywebchromeclient extends webchromeclient {     @override     public boolean onjsconfirm(webview view, string url, string message, final jsresult result) {         new alertdialog.builder(myapp)         .settitle("app titler")         .setmessage(message)         .setpositivebutton(android.r.string.ok,                 new dialoginterface.onclicklistener()         {             public void onclick(dialoginterface dialog, int which)             {                 result.confirm();             }         })         .setnegativebutton(android.r.string.cancel,                 new dialoginterface.onclicklistener()         {             public void onclick(dialoginterface dialog, int which)             {                 result.cancel();             }         })         .create()         .show();          return true;     } } 

don't forget set webchromeclient in webview...

    mwebview.setwebchromeclient(new mywebchromeclient()); 

note.. isn't code, found , works handling javascript confirmation dialogs in webview!

cheers!


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -