How can I change Swingworker to AsyncTask in Android?
How can I change Swingworker to AsyncTask in Android?
My code is as follows.
private void showWeather() {
// TODO Auto-generated method stub
SwingWorker worker = new SwingWorker<WeatherInfo,Object>()
{
public WeatherInfo doInBackground()
开发者_如何学Go {
YahooWeather yahooWeather = new YahooWeather();
return yahooWeather.getWeatherInfo();
}
public void done()
{
try {
WeatherInfo wInfo = get(); // get WeatherInfo result from background thread
updateGUI(wInfo);
}
catch(Exception e){}
}
};
worker.execute();
}
You should be using AsyncTask instead
精彩评论