I'm trying to share some data from an Activity to JavaScript, but all my results have failed, this is my current code:
C#
var webView = FindViewById<WebView>(Resource.Id.webView);
webView.SetWebChromeClient(new WebChromeClient());
webView.Settings.JavaScriptCanOpenWindowsAutomatically = true;
webView.Settings.JavaScriptEnabled = true;
string script = string.Format("javascript:UpdateData('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}');", "1", "2", "3", "4", "5", "6", "7", "8", "9");
webView.LoadUrl("file:///android_asset/index.html");
if (Build.VERSION.SdkInt >= BuildVersionCodes.Kitkat)
{
webView.EvaluateJavascript(script, null);
}
else
{
webView.LoadUrl(script);
}
JavaScript inside of index.html (I tried to add the code in the head and in the end of the body too):
<script type="text/javascript">
function UpdateData(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9) {
alert("Hi");
}
</script>
AndroidManifest.xml
<?xml version="1.0" encoding"utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="Test.Test" android:versionCode="1" android:versionName="1.0">
<uses-sdk android:minSdkVersion="19" />
<application android:label="Test"></application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Honestly, I don't know what I'm doing wrong because nothing happens, the basic web page is rendered perfectly, but the JavaScript is not triggered. Has anyone experienced this before?

