3

I have an html page loaded in Android WebView.

I am attempting to execute a java script function using the MotionEvenAction.Down event.

Here is the code that's not working

 webView.Touch += (s, e) =>
        {
            if (e.Event.Action == MotionEventActions.Down)
            {
                webView.EvaluateJavascript(((string.Format("poweSelected({0})", 3), new JavascriptResult() ));

            }

        };


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

    }
}

I am getting the error message -- (EvaluateJavascript has red line under it)

There is no argument given that corresponds to the required formal parameter 'resultCallback' of 'WebView.EvaluateJavascript(string, IValueCallback)'

As far as I knwo i am implemetnting the ivaluecallback interface correctly and I have found examples exactly like the that seem to be working.

Any help would be appreciated Mark

1
  • Typo in your code, try: webView.EvaluateJavascript(string.Format("poweSelected({0})", 3), new JavascriptResult()); Commented Mar 7, 2018 at 0:14

1 Answer 1

2

Like @Sushi has mentioned:

Replace this:

 webView.EvaluateJavascript(((string.Format("poweSelected({0})", 3), new JavascriptResult() ));

with:

webView.EvaluateJavascript(string.Format("poweSelected({0})", 3), new JavascriptResult());
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks it just takes another set of eyes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.