The following code is designed within a Fragment to call a javascript file (MyMap) and call a function (updateJSONandMap). The function itself sends a JSON to a server and takes three parameter. It works while the first parameter is hardcoded ("Incident") but will not work when I create a variable.
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setDomStorageEnabled(true);
webview.loadUrl("file:///android_asset/MyMap.html");
webview.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
webview.loadUrl("javascript:updateJSONandMap('Incident'," + latitude + "," + longitude + ")");
}
});
The block of text of the JSON is a string
Event: {
Action: 'PUT',
Value: {"S": UserEvent}
},
The obvious create a variable
final String incident = "incident2";
and then
webview.loadUrl("javascript:updateJSONandMap(" + incident + "," + latitude + "," + longitude + ")");
does not create an error, but does not send the JSON to the server