Android进度对话框或定位更改
您好,我有这样的问题,我有一个asynctask和progress对话框,当我旋转手机时,它失败了,我知道该活动已取消,我们需要创建新的。所以代码Android进度对话框或定位更改,android,Android,您好,我有这样的问题,我有一个asynctask和progress对话框,当我旋转手机时,它失败了,我知道该活动已取消,我们需要创建新的。所以代码 而且它在失败的时候失败了。如何修复?谢谢。为什么进度对话框是静态的?@blackbelt i删除静态-相同 public class GetWeather extends AsyncTask<String, Void, WeatherInfo> { FragmentActivity activity; public Get
而且它在失败的时候失败了。如何修复?谢谢。为什么进度对话框是静态的?@blackbelt i删除静态-相同
public class GetWeather extends AsyncTask<String, Void, WeatherInfo> {
FragmentActivity activity;
public GetWeather(FragmentActivity a){
activity = a;
}
static ProgressDialog progressDialog;
public void showDialog() {
progressDialog = new ProgressDialog(activity);
/*Some stuff for dialog*/
progressDialog.show();
}
@Override
protected void onPreExecute() {
showDialog();
}
protected void onPostExecute(WeatherInfo result){
progressDialog.dismiss();
}
}
public class MyActivity extends FragmentActivity implements CityList.OnItemSelectedListener {
GetWeather weather = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
weather = (GetWeather) getLastCustomNonConfigurationInstance();
if (weather != null){
weather.activity = this;
weather.showDialog();
}