I am very new to Android and developing my first app. My Version is 6.0 and API veresion is 21.
My app is having a textbox and a button in its home page. I am putting my url and hit submit button so that a webview will loads this url. In my url I included some javascript functions, they are defined to retuning some values. I am trying to get that value and assign the value to other textbox. I tried in two ways but none of them worked for me. First I created a new class as follows, public class JsInterface { private String val; @JavascriptInterface void receiveString(String value) { Log.d("This is what from JS-", value); val = value; } String Val() { return val; } } My JS function function goAndroid(Go Value to Script){ var goString = "Hello " + Go Value to Script; window.MyAndroidApp.receiveString(goString); } In mainActivity.java WebView.addJavascriptInterface(new JsInterface(), "MyAndroidApp"); WebView.loadUrl("javascript:goAndroid('Go Value to Script')") //Below value is null.. System.out.println(new JsInterface().Val()); Here the system out comes nothing... Second As I am using API version 21, I followed the another way, webView.evaluateJavascript("(function() { return goAndroid('My Value'); })();", new ValueCallback() { @Override public void onReceiveValue(String s) { Log.d("LogName--------------", s); } }); Here I am getting a small popup which says " unfortunately, app has stopped". In LogCat I am getting the following error 05-10 17:36:13.922: E/AndroidRuntime(822): FATAL EXCEPTION: main 05-10 17:36:13.922: E/AndroidRuntime(822): java.lang.NoSuchMethodError: android.webkit.WebView.evaluateJavascript 05-10 17:36:13.922: E/AndroidRuntime(822): at com.example.asdf.MainActivity$5.onClick(MainActivity.java:209) Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To unsubscribe from this group and stop receiving emails from it, send an email to android-developers+unsubscr...@googlegroups.com. To post to this group, send email to android-developers@googlegroups.com. Visit this group at https://groups.google.com/group/android-developers. To view this discussion on the web visit https://groups.google.com/d/msgid/android-developers/40f50d29-0eb5-4dec-a006-2442def86d8b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.