Thanks Mike, that was very helpful! I'll See if I can use the info to get my example working correctly, and post it for the next person...
On May 10, 9:05 am, Mike dg <vinb...@gmail.com> wrote: > Evan Charlton wrote a great article that might help you. > > http://evancharlton.com/thoughts/rotating-async-tasks/ > > -Mike dg > > On May 10, 12:37 am, Aaron <aobrien...@gmail.com> wrote: > > > > > > > I have a managed ProgressDialog that show the status as tasks are > > moving along. The Activity.show is kicked off by an AsyncTask > > progressUpdates and the final Activity.closeDialog is called through > > the AsyncTask as well. Everything works beautifully as long as the > > screen is not rotated... > > > What am I doing wrong? I thought having the Activity manage my dialog > > would solve this for me... Here is the code I'm playing with: > > > public class Enter extends Activity { > > ProgressDialog progressDialog; > > private final static int PROGRESS_DIALOG_ID = 1; > > > @Override > > public void onCreate(Bundle savedInstanceState) { > > super.onCreate(savedInstanceState); > > setContentView(R.layout.main); > > > Button button = (Button)findViewById(R.id.progressbar_button); > > > button.setOnClickListener(new View.OnClickListener(){ > > > @SuppressWarnings("unchecked") > > public void onClick(View v) { > > > Enter.this.showDialog(PROGRESS_DIALOG_ID); > > new AsyncTask(){ > > > @Override > > protected Object > > doInBackground(Object... params) { > > progressDialog.setMax(30); > > for (int a = 0; a < 30; > > a++){ > > publishProgress(new > > Integer((a+1))); > > try { > > > > Thread.sleep(1000); > > > > Log.d("Enter", "Click: " + a); > > } catch > > (InterruptedException e) { > > > > e.printStackTrace(); > > } > > } > > return null; > > } > > > @Override > > protected void > > onProgressUpdate(Object... values) { > > > > super.onProgressUpdate(values); > > Integer progress = > > (Integer)values[0]; > > > > progressDialog.setProgress(progress.intValue()); > > } > > > @Override > > protected void onPostExecute(Object > > result) { > > super.onPostExecute(result); > > > > Enter.this.dismissDialog(PROGRESS_DIALOG_ID); > > } > > }.execute((Object[]) null); > > } > > }); > > } > > > @Override > > protected Dialog onCreateDialog(int id) { > > Dialog dialog = null; > > if (id == PROGRESS_DIALOG_ID){ > > progressDialog = new ProgressDialog(this); > > > progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL); > > progressDialog.setTitle("Pleae Wait"); > > progressDialog.setMessage("Running a long process..."); > > progressDialog.setCancelable(true); > > dialog = progressDialog; > > } > > return dialog; > > } > > > Thanks! > > > -Aaron > > > -- > > You received this message because you are subscribed to the Google > > Groups "Android Developers" group. > > To post to this group, send email to android-developers@googlegroups.com > > To unsubscribe from this group, send email to > > android-developers+unsubscr...@googlegroups.com > > For more options, visit this group > > athttp://groups.google.com/group/android-developers?hl=en > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group > athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en