Search code examples
androidorientationoncreatecrash

application crashes on orientation change while using progressDialog with threading


--> I've implemented threading in my first activity. And made the use of progress dialog also. So now during the orientation (of that screen only) my application crashes - gives exception of memory Leaked. And as a solution of this I came to know from here only that I should put

android:configChanges="keyboardHidden|orientation"

But now my onCreate() method of that activity is not getting called, and it is necessary for me to call this method on orientationChanges. So what should I do at this stage?


Solution

  • Check out this blog:

    http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/

    There are also other similar questions here on stackoverflow: How to handle screen orientation change when progress dialog and background thread active?

    I have experienced, if using the first option, that the emulator has a bug which makes it call onCreate() twice - causing a crash, but it shouldn't be an issue on a real device.