I'm tring to pass a multi-dimensional array using Javascript interface but it returns null when I get on the device.
Here is my javascript interface:
@JavascriptInterface
public void showHTML(final String html) {
this.html = html;
processed = true;
webView.loadUrl("javascript:" +
"var html = document.documentElement.innerHTML;" +
"var pre = html.indexOf('[{');" +
"var data = html.substring(pre, pre + html.substring(pre).indexOf(';'));" +
"var json = JSON.parse(data);" +
"var array = [];" +
"var obj;" +
"for (i = 0; i<json.length; i++){" +
"obj = json[i];" +
"array.push([obj.StationName, obj.StationCode, obj.CountryName]);" +
"}" +
"window.Android.getData(array, json[0].StationName);");
}
I'm tring to pass the variable array and the json[0].StationName
is for test only.
Here is my getData():
@JavascriptInterface
public void getData(Object array, String test){
Log.d("CPA", test);
if(array == null){
Log.d("CPA", "array is null");
}
}