Forum Xamarin.Android

WebView EvaluateJavascript return value with IValueCallBack

What is the best way to return the javascript results with the Android EvaluateJavascript? Below is my attempt but I am getting an error of "An unhandled exception occurred" when calling EvaluateJavascript.

JavascriptResult jsr = new JavascriptResult();

string js = "function myFunction(value1, value2) { if value1 > value2 return true else return false}};";
js += "myFunction(100, 50);";

webview.EvaluateJavascript("javascript:" + js, jsr);

result = jsr.Result;

public class JavascriptResult : Java.Lang.Object, IValueCallback
{
public string Result;
public void OnReceiveValue(Java.Lang.Object result)
{
Result = ((Java.Lang.String)result).ToString();
}
}

Answers

Sign In or Register to comment.