I have a webview that ignores all my javascript interface methods, or at least appears to. When I run the website from a normal browser, it throws errors because the interface isn't defined, as expected, but this leads me to believe that the interface methods are at least being called, but something else is wrong. Can anyone help me figure out what?
Declaring stuff
@Override
protected void onPostExecute(ValidationResult validation)
{
if (validation.wasSuccessful)
{
URL = validation.message;
wv = (WebView) findViewById(R.id.webView);
wv.addJavascriptInterface(new KioskInterface(wv.getContext()), "Android");
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
wv.loadUrl(URL);
}
else
{
errorAlert(title, msg + "\nContact network management.");
}
}
Kiosk Interface class
public class KioskInterface {
Context c;
KioskInterface(Context context)
{
c = context;
}
@JavascriptInterface
public void showToast()
{
Toast.makeText(c, "Hiding Keyboard", Toast.LENGTH_LONG).show();
}
}
Javascript
function example() {
Android.showToast();
}
I never see any the Toast, but I don't get any errors or broken behavior either.