My WebView
is supposed to load manipulated HTML saved in /klw.html. I am using the code
mWebView.loadUrl("file:///android_asset/klw.html");
. However, when testing it on the emulator, I keep getting a "Webpage not available" error. What could be causing this issue? Could it be that I need to load it from a different directory?
Below is the code snippet:
public class Stundenplan extends Activity {
String url = "http://info.tam.ch/display/timetable_external.php?school=klw&sem=54&class=26&week=16";
Document document;
public void main(String... args){
try {
document = Jsoup.connect(url).get();
}
catch (IOException e) {
e.printStackTrace();
}
Element head = document.head();
head.append("<link rel=\"stylesheet\" href=\"klw.css\">");
String html = document.html();
String charset = Jsoup.connect(url).response().charset();
try {
Writer writer = new PrintWriter("/klw.html", charset);
writer.write(html);
writer.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
main();
WebView mWebView;
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mWebView = (WebView) findViewById(R.id.webView);
mWebView.setWebViewClient(new WebViewClient());
mWebView.getSettings().setDomStorageEnabled(true);
mWebView.getSettings().setSupportZoom(true);
mWebView.loadUrl("file:///android_asset/klw.html");
}
}