i start a activity and i call this download method in on create
public void download(){
thread = new Runnable () {
public void run() {
try{
/* Get a SAXParser from the SAXPArserFactory. */
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
Get the XMLReader of the SAXParser we created. */
XMLReader xr = sp.getXMLReader();
/*
* Create a new ContentHandler and apply it to the
* XML-Reader */
WeatherHandler gwh = new GoogleWeatherHandler();
xr.setContentHandler(gwh);
/* Parse the xml-data our URL-call returned. */
temp////is a url defined
xr.parse(new InputSource(temp.openStream()));
ws = gwh.getWeatherSet();
}
catch(Exception e){
}
}new Thread(thread).start();
}
Problem is that it works if I debug and actually go over the line thread.start, if not the thread does not start? how can i just download info from a website?
Usually the right way to do an asynchronous task in Android is by implementing a task that extends
AsyncTask.