java - android thread crashes when screen orientation changes -


i making android app, needs download text url , show on alertdialog.

i created new thread. thread reads file on web, progressdialog appears before thread starts, thread packages file content web on bundle , , passes handler, handler stops progress, , shows text bundle on alertdialog. works pretty good, when screen orientation changes when progressdialog shown , thread running, app crashes. ideas on how fix thing?

any appreciated. :)

when orientation changes, os shut down activity , restart it. mess download thread. 1 solution might work save thread object non-configuration data. you'll need override onretainnonconfigurationinstance() in activity. however: not if thread object has references view- or activity-related object. cause huge memory leak , make users unhappy quickly.

see guide topic handling runtime changes details on using onretainnonconfigurationinstance() , alternative approach. see article avoiding memory leaks on ... well, that.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -