I have a webview element containing a jqmath script that I load from an external script in android studio, the function to pass variables into the script looks like this:
void UpdateFunc() {
js = "<html><head>"
+ "<link rel='stylesheet' href='file:///android_asset/mathscribe/jqmath-0.4.3.css'>"
+ "<script src='file:///android_asset/mathscribe/jquery-1.4.3.min.js'></script>"
+ "<script src='file:///android_asset/mathscribe/jqmath-etc-0.4.3.min.js'></script>"
+ "</head><body>"
+ "<script>var s = '$$" + functext + "$$';M.parseMath(s);document.write(s);</script> </body>";
webView.loadDataWithBaseURL("", js, "text/html", "UTF-8", "");
}
I require to run some functions and I have been suggested to extend use WebViewClient and run OnPageFinished(), my code as follows (under OnCreate):
webView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
code
}
});
The issue is, OnPageFinished gets called before the script finished updating the webview.
Is there any method I could undertake t hat would allow me to run code immediately after the script finished updating the webview? Or how to fix the issue with OnPageFinished? Note also that I did not pass any variables in the function seeing as I have only one webview.
Thanks in advance.