// Javascript inabled on webviewmWebview.getSettings().setJavaScriptEnabled(true);
mWebview.addJavascriptInterface(new Object() { @JavascriptInterface // For API 17+ public void exitApp() { // Deal with a click on the OK button finish(); } }, "ok");
In Html Page
<center>
<button onclick="ok.exitApp()" style="color: #fff; background-color: #d9534f;">Click here to Exit</button>
</center>
Another Way
Code in HTML
<button type="button" value="someValue" onclick="ok.performClick(this.value);">OK</button>
Java:
WebSettings ws = wv.getSettings();
ws.setJavaScriptEnabled(true);
wv.addJavascriptInterface(new Object()
{
@JavascriptInterface // For API 17+ Important Line
public void performClick(String strl)
{
stringVariable = strl;
Toast.makeText (YourActivity.this, stringVariable, Toast.LENGTH_SHORT).show();
}
}, "ok");
0 comments:
Post a Comment