It didn't seem like there was a post about this, so here goes. I've been working on a simple app to grab my time table from my school, and get it on my phone. Currently I'm working on the port on android but I've hit an issue. I get the error:
java.io.IOException: -1 error loading URL urladress.
Code:
public void updateTimeTable(){
//Get UID and Birthday
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String uid = prefs.getString("uid", "000000");
String fods = prefs.getString("fodsdag", "000000");
//Set URL
String url = "http://unv1.aalborg-stu.dk/cgi-bin/elevskema.pl?ugen=0&unavn=" + uid + "&fodsdag=" + fods;
try {
Document doc = Jsoup.connect(url).get();
Elements td = doc.getElementsByTag("td");
//ArrayList<String> tdArray = new ArrayList<String>();
// for (Element tds : td) {
// String tdText = tds.text();
// tdArray.add(tdText);
//}
//String[] data = tdArray.toArray(new String[tdArray.size()]);
} catch (IOException e ){
Log.e("Parser", "shite", e);
}
Context context = getApplicationContext();
CharSequence text = url;
int duration = Toast.LENGTH_SHORT;
Toast toast = Toast.makeText(context, text, duration);
toast.show();
}
I've commented some lines out to identify where the issue is, and it seems it's at the actual parsing. Anywho, screenshot of the error I get:
Screenshot
I got about 4 days worth of Java experience so forgive me if it's something silly.
Best Regards