如何在Android中将Swingworker更改为AsyncTask?
我的代码如下。
private void showWeather() {
// TODO Auto-generated method stub
SwingWorker worker = new SwingWorker<WeatherInfo,Object>()
{
public WeatherInfo doInBackground()
{
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();
}