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

前端 未结 28 1256
轮回少年
轮回少年 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 08:08

    Edit: Google engineers do not recommend this approach, as described by Dianne Hackborn (a.k.a. hackbod) in this StackOverflow post. Check out this blog post for more information.


    You have to add this to the activity declaration in the manifest:

    android:configChanges="orientation|screenSize"
    

    so it looks like

    
    

    The matter is that the system destroys the activity when a change in the configuration occurs. See ConfigurationChanges.

    So putting that in the configuration file avoids the system to destroy your activity. Instead it invokes the onConfigurationChanged(Configuration) method.

提交回复
热议问题