I have used JavaScript code to android using this one THIS DOCUMENT but i'am not getting String value why i am facing this problem ,any one have idea on this one, help me.
This is my code
webview = (WebView) findViewById(R.id.webView);
webview.getSettings().setJavaScriptEnabled(true);
String html = " <input type='button' value='Say hello' onClick='showAndroidToast('Hello Android!')' />" +
"<script type='text/javascript'> function showAndroidToast(toast) { Android.showToast(toast); }</script>";
webview.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null);
webview.addJavascriptInterface(new WebAppInterface(MainActivity.this), "Android");
And WebAppInterface class like this
public class WebAppInterface {
Context mContext;
/** Instantiate the interface and set the context */
WebAppInterface(Context c) {
mContext = c;
}
/** Show a toast from the web page */
@JavascriptInterface
public void showToast(String toast) {
Log.i(" ", " " + toast);
Toast.makeText(mContext, toast, Toast.LENGTH_LONG).show();
}
}