-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Guys i am in a big trouble and having a big problem in rendering mathml in android:
its a weird problem: When i start the activity which renders mathml using mathjax, then it doesnt display anything but after i re-launch the project with no modification, same activity renders mathml perfectly into webview :(
Here is my code
void loadwebview(String txt)
{
wq = (WebView) findViewById(R.id.qtext);
wq.getSettings().setJavaScriptEnabled(true);
// wq.getSettings().setBuiltInZoomControls(true);
wq.getSettings().setLoadWithOverviewMode(false);
wq.loadDataWithBaseURL("http://bar", "<script type='text/x-mathjax-config'>"
+"MathJax.Hub.Config({ "
+"showMathMenu: false, "
+"jax: ['input/MathML','output/HTML-CSS'], " // output/SVG
+"extensions: ['mml2jax.js'], "
+"TeX: { extensions: ['noErrors.js','noUndefined.js'] }, "
+"'SVG' : { blacker: 30, "
+"styles: { path: { 'shape-rendering': 'crispEdges' } } } "
+"});</script>"
+"<script type='text/javascript' "
+"src='file:///android_asset/MathJax/MathJax.js'"
+"></script>", "text/html", "utf-8", "");
Log.e("Loading","wq");
}
void next_content(int count)
{
s=count;
count=count+qcounter;
SharedPreferences sharedPref = getApplicationContext().getSharedPreferences("questionbank", Context.MODE_PRIVATE);
questn = sharedPref.getString(c_id + "question" +ch_id+"chid"+ count, "
-
");a1 = sharedPref.getString(c_id+"answ1"+ch_id+"chid"+count, "
-
");a2 = sharedPref.getString(c_id+"answ2"+ch_id+"chid"+count, "
-
");a3= sharedPref.getString(c_id+"answ3"+ch_id+"chid"+count, "
-
");a4 = sharedPref.getString(c_id+"answ2"+ch_id+"chid"+count, "
-
");cans = sharedPref.getString(c_id+"cans"+ch_id+"chid"+count, "
-
");String ans="";
if(a1.length()>3)
ans="
(A) "+a1.substring(3);
else
ans="
(A)None of these
";if(a2.length()>3)
ans=ans+"
(B) "+a2.substring(3);
else
ans=ans+"
(B)None of these
";if(a3.length()>3)
ans=ans+"
(C) "+a3.substring(3);
else
ans=ans+"
(C)None of these
";if(a4.length()>3)
ans=ans+"
(D) "+a4.substring(3);
else
ans=ans+"
(D)None of these
";ans=ans+"
questn=questn+"
if (android.os.Build.VERSION.SDK_INT < 19)
{
wq.loadUrl("javascript:document.getElementById('math').innerHTML='"
+ "<math xmlns="http://www.w3.org/1998/Math/MathML\">"
+ "<mstyle displaystyle="true">"
+ doubleEscapeTeX(questn+ans)
+ "';");
wq.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
}
else
{
wq.evaluateJavascript("javascript:document.getElementById('math').innerHTML='"
+ "<math xmlns="http://www.w3.org/1998/Math/MathML\">"
+ "<mstyle displaystyle="true">"
+ doubleEscapeTeX(questn+ans)
+ "';",null);
//wq.evaluateJavascript("javascript:document.getElementById('math').innerHTML='<font color="#000000">
"+doubleEscapeTeX(questn+ans)+"';",null);wq.loadUrl("javascript:MathJax.Hub.Queue(['Typeset',MathJax.Hub]);");
}
nofqus.setText("You are on"+" "+s+" "+"of"+" "+"10"+" "+"question");
Log.e("ans ","\n"+ questn+"\n"+ans);
}
in oncreate method i call loadwebview("") and nextcontent(c++)