I specifically want to call Android, when in offline mode, for a large chunk of data to be returned to JavaScript.
This is a doable solution for small amounts of data:
(Android)
mWebView.loadUrl("javascript:(function () { " +
"setVariable("+valueToSetInHtmlPage+");" +
"})()");
(HTML callback function)
function setVariable(AndroidInput)
{
alert(AndroidInput);
}
This approach is limited by the allowed URL size which might very between browsers.
But never the less a blocking limit when dealing with large data (+10KB)
Is there any other ways to pass values from Android to JavaScript?
You should probably look into WebView’s addJavascriptInterface function. This’ll let you “hand over” a Java object into JS.