[android-developers] Re: Proper way of handling orientation change + async thread
well i am answering my own question again. I figured out a working solution, for those who are interested, see http://bend-ing.blogspot.com/2008/11/properly-handle-progress-dialog-in.html On Nov 4, 9:52 am, zl25drexel [EMAIL PROTECTED] wrote: Thanks for your reply, any example codes? On Nov 3, 8:28 pm, Greg [EMAIL PROTECTED] wrote: When you change orientation your Activity is destroyed and then re- created. When you re-create the dialog view object that was sent to the background process is no longer valid, thus the error. There are probably several ways to handle this but the first that comes to my mind is: 1) The background thread should not be trying to manipulate views directly. Have it send a 'cancel' message to a handler in one of your UI classes (like the main activity). The UI class can then take the appropriate action to cancel the dialog. 2) If orientation can change while you have the dialog up (which it can), then you need to save that state when the activity is stopped and have your restart handler take care of recreating the dialog and displaying it when the activity is restarted (after orientation change). Your message handler should then take the cancel message from the background thread and dismiss the dialog if it exists. Hope this helps, Greg --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Proper way of handling orientation change + async thread
Maybe we need a Self Help section. ;-) Thanks for posting your self-answers, since they still help everyone. On Wed, Nov 5, 2008 at 1:08 PM, zl25drexel [EMAIL PROTECTED] wrote: well i am answering my own question again. I figured out a working solution, for those who are interested, see http://bend-ing.blogspot.com/2008/11/properly-handle-progress-dialog-in.html On Nov 4, 9:52 am, zl25drexel [EMAIL PROTECTED] wrote: Thanks for your reply, any example codes? On Nov 3, 8:28 pm, Greg [EMAIL PROTECTED] wrote: When you change orientation your Activity is destroyed and then re- created. When you re-create the dialog view object that was sent to the background process is no longer valid, thus the error. There are probably several ways to handle this but the first that comes to my mind is: 1) The background thread should not be trying to manipulate views directly. Have it send a 'cancel' message to a handler in one of your UI classes (like the main activity). The UI class can then take the appropriate action to cancel the dialog. 2) If orientation can change while you have the dialog up (which it can), then you need to save that state when the activity is stopped and have your restart handler take care of recreating the dialog and displaying it when the activity is restarted (after orientation change). Your message handler should then take the cancel message from the background thread and dismiss the dialog if it exists. Hope this helps, Greg --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Proper way of handling orientation change + async thread
Thanks for your reply, any example codes? On Nov 3, 8:28 pm, Greg [EMAIL PROTECTED] wrote: When you change orientation your Activity is destroyed and then re- created. When you re-create the dialog view object that was sent to the background process is no longer valid, thus the error. There are probably several ways to handle this but the first that comes to my mind is: 1) The background thread should not be trying to manipulate views directly. Have it send a 'cancel' message to a handler in one of your UI classes (like the main activity). The UI class can then take the appropriate action to cancel the dialog. 2) If orientation can change while you have the dialog up (which it can), then you need to save that state when the activity is stopped and have your restart handler take care of recreating the dialog and displaying it when the activity is restarted (after orientation change). Your message handler should then take the cancel message from the background thread and dismiss the dialog if it exists. Hope this helps, Greg --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Proper way of handling orientation change + async thread
When you change orientation your Activity is destroyed and then re- created. When you re-create the dialog view object that was sent to the background process is no longer valid, thus the error. There are probably several ways to handle this but the first that comes to my mind is: 1) The background thread should not be trying to manipulate views directly. Have it send a 'cancel' message to a handler in one of your UI classes (like the main activity). The UI class can then take the appropriate action to cancel the dialog. 2) If orientation can change while you have the dialog up (which it can), then you need to save that state when the activity is stopped and have your restart handler take care of recreating the dialog and displaying it when the activity is restarted (after orientation change). Your message handler should then take the cancel message from the background thread and dismiss the dialog if it exists. Hope this helps, Greg --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---