0

I would like to use the Android WebView EvaluateJavascript method with Xamarin in Visual Studio but this method is not available :

enter image description here

Is there a way to use this method with Xamarin ?

1 Answer 1

2

You would need to use API Level 19, otherwise it is not available. If you don't want to use API 19 then consider using LoadUrl("javascript:").

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I see that the EvaluateScript method doesn't return anything... Is there a way to call a JavaScript method and get the returned value ?
I am not sure if there is a way to get the return value. If the function is your own you could send in a "callback". I have written some samples on how to create a cross-platform WebView hybrid, in Android's case you would use WebViewClient and parse out the URI in ShouldOverrideUrlLoading. Here is a link to the Android portion of the partial class WebHybrid: github.com/sami1971/SimplyMobile/blob/master/Core/… and the common(-ish) code portion: github.com/sami1971/SimplyMobile/blob/master/Core/…
create an interface using addjavascriptinterface. Create a method in it, then you can call this method from the javascript and send it the value you want to return. Then you can use this value in your android java code.

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.