Within my Android app assets, I have stored an HTML page that I want to display using a WebView and add parameters to the webpage.
To achieve this, I populated all the values in a JSONArray and utilized 'addJavascriptInterface' to incorporate this JSONArray into the webpage's JavaScript.
However, when attempting to access the value in JavaScript, it appears as [object Object] with an undefined length...
JSONArray json = buildJSONArray();
webView.setWebViewClient(new WebViewClient());
webView.getSettings().setJavaScriptEnabled(true);
webView.addJavascriptInterface(json, "data");
webView.loadUrl("file:///android_asset/test.html");
I tried replacing the JSONArray with a simple String, but encountered the same issue...
How can I effectively send a JavaScript parameter to my HTML page from Android? It seems like there is something missing in the implementation of the 'addJavascriptInterface' method...
Any help or guidance on this matter would be greatly appreciated :)