How to handle screen orientation change when progress dialog and background thread active?

前端 未结 28 1581
轮回少年
轮回少年 2020-11-22 07:03

My program does some network activity in a background thread. Before starting, it pops up a progress dialog. The dialog is dismissed on the handler. This all works fine, exc

28条回答
  •  青春惊慌失措
    2020-11-22 07:52

    Seems far too 'quick and dirty' to be true so please point out the flaws but what I found worked was...

    Within the onPostExecute method of my AsyncTask, I simply wrapped the '.dismiss' for the progress dialog in a try/catch block (with an empty catch) and then simply ignored the exception that was raised. Seems wrong to do but appears there are no ill effects (at least for what I am doing subsequently which is to start another activity passing in the result of my long running query as an Extra)

提交回复
热议问题