javascript - WebChromeClient OnJSAlert is not called -


i'm running js script in webview. script alerts message webview, , want receive in app. problem onjsalert not called nor can use @override annotaion when definig method.
imports -

import android.webkit.webchromeclient; import android.webkit.webview; import android.webkit.webviewclient; import android.webkit.jsresult; import android.webkit.websettings; 

i use webview -

webview = (webview)findviewbyid(r.id.webview1);  webview.getsettings().setjavascriptenabled(true); webview.setwebchromeclient(new webchromeclient() {         @override         public void onprogresschanged(webview view, int newprogress) {             if (newprogress == 100) {             log.d("fibi", "finished loading");             }         }         //@override //if uncomment compilation error         public boolean onjsalert(webview view, string url, string message, final jsresult result) {             encresult = message;             log.d("fibi", encresult);             result.cancel();             return true;                         }     }); webview.loadurl("file:///android_asset/test.html"); 

and html code test.html

 <html>    <body >      <div onclick="alert('click')"> click me !!  </div>    </body> </html> 

when run app, html file loads , onprogresschanged been called - can see log message says "finished loading". when click on link @ loaded page, onjsalert not called - don't log message , instead can see dialog window pops on device alert message.
if try use @override annotaion @ beginning of onjsalert, error - "the method onjsalert(webview, string, string, jsresult) of type mainactivity.mywebclient must override or implement supertype method".
ideas?

if use method name without proper spelling, method calls not work

onjsalert

change to:

onjsalert


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -