Android's WebView executes JavaScript asynchronously and passes the result of the execution in a ValueCallback later.
I'm not familiar with Xamarin exactly, but if you can share some of your Android C# code, may be able to help better.
From a Java perspective, where my experience lies:
Essentially, you need to instantiate a ValueCallback object that implements the onReceiveValue
function. When the javascript that you have evaluated finishes executing, the function you declared will be executed, passing in the result of that evaluation as a paramter that is string of JSON. You should then be able to retrieve the result from that JSON.
Hope this helps!
Update: cobbling together some C# that might help. Caveat: I've never written a line of c# before this. But hopefully if it's not quite right will set you on the right path :-)
class JavaScriptResult : public IValueCallback {
public void OnReceiveValue(Java.Lang.Object result) {
Java.Lang.String json = (Java.Lang.String) result;
// |json| is a string of JSON containing the result of your evaluation
}
}
Then you can presumably say something along the lines of
web_view.EvaluateJavaScript("function() { alert('hello world'); return 42; }()",
new JavaScriptResult());