1

I am trying to display MathJax CDN onto my Android app using WebView. I created a LaTex code here. Please help me display this html on my android app.

Result after Deployement

Thanks

Sabiha Taskin
  • 113
  • 11
  • What did you try to resolve this problem? – Jeroen Heier Dec 27 '16 at 08:28
  • I tried using Asset but again I actually want to do it with CDN. Also do you think jqMath would help? – Sabiha Taskin Dec 27 '16 at 08:37
  • There should be no difference between CDN and a local version. You are following the code showed in the [getting started](http://docs.mathjax.org/en/latest/start.html) section. Try using the working [example](https://cdn.mathjax.org/mathjax/latest/test/sample-mml.html) first. – Jeroen Heier Dec 27 '16 at 08:48
  • Yeah, this is not a problem, but when I do a Webview at my Android code, it does not show. Says "File not available". – Sabiha Taskin Dec 27 '16 at 08:51
  • May [this](https://developer.chrome.com/multidevice/webview/gettingstarted#enable_javascript) howto page could help. Did you enable JavaScipt and set the right permissions? – Jeroen Heier Dec 27 '16 at 09:12
  • Yeah I used Internet Permission. Also I tried the sample example you suggested and it goes displayed. But when I use my own LaTex html, it doesnot. This is mine: wq.loadUrl("file:///D:/circleeq.html"); Sample example: wq.loadUrl("https://cdn.mathjax.org/mathjax/latest/test/sample-mml.html"); – Sabiha Taskin Dec 27 '16 at 10:08
  • You should your use the Assets folder. Look at [this](http://www.android-examples.com/load-local-html-file-in-webview-on-android/) example. – Jeroen Heier Dec 27 '16 at 18:12
  • I tried the way showed, but doesnot work. I have added a pic on my original question. Please see – Sabiha Taskin Dec 29 '16 at 06:02
  • You are giving wrong URL to load the file from assets check [this link](http://stackoverflow.com/questions/3152422/webview-load-html-from-assets-directory) – shadygoneinsane Dec 29 '16 at 06:13
  • @shadygoneinsane So its should be `wq.loadUrl("file:///android_asset/circleeq.html");` in my case right? – Sabiha Taskin Dec 29 '16 at 08:34
  • I have written the code in the answer – shadygoneinsane Dec 29 '16 at 08:42
  • Thanks, but my html file consisted of an equation which I did using Latex. I have added a picture of what I was suppose to get, and what I am getting actually. – Sabiha Taskin Dec 29 '16 at 08:44
  • Yes it will work as you expected that i am sure :) – shadygoneinsane Dec 29 '16 at 08:50
  • No I am not getting the expected result. Equation is coming in LaTex syntax. Since I am new user, Stackoverflow doesnot allow me to put two images without 10 reputation. – Sabiha Taskin Dec 29 '16 at 08:57
  • Have a look at this [SO](http://stackoverflow.com/questions/6750657/android-webview-doesnt-load-jquery) question and the code suggested in the answers. To verify everything else you could put the library also in the assets folder (change the reference in the HTML). Have a good new year ;-) – Jeroen Heier Dec 31 '16 at 07:51
  • Since I am using LaTex in my HTML file so I am using MathJax as ` – Sabiha Taskin Dec 31 '16 at 09:47

1 Answers1

1

You are giving the wrong URL for your Assets file

Instead of getting the html file from assets of your app on mobile device you have given the location of your app code on your machine.

so change the URl to this and it will work :

 WebView wq;
    wq = (WebView) findViewById(R.id.webView1);
    WebSettings websettings = wq.getSettings();
    websettings.setJavaScriptEnabled(true);

    wq.loadUrl("file:///android_asset/circleeq.html");
shadygoneinsane
  • 2,226
  • 1
  • 24
  • 47