Lock orientation until Asynctask finish

前端 未结 3 1686
别跟我提以往
别跟我提以往 2021-02-08 10:41

Only want to block orientation until all the data is loaded in my view. So I thought about the following code but it doesn\'t work.

private class task extends As         


        
3条回答
  •  孤独总比滥情好
    2021-02-08 10:48

    Probably a bug, but maybe a better way would be to either lock your orientation so you dont need to worry about the activity being created... OR better yet.

    Use this in your manifest for the activity:

    android:configChanges="orientation|screenSize|screenLayout"
    

    Then your activity isn't recreated on rotate (also as of HoneyComb/3.0 Activities aren't re-created on rotate).

    Just override the:

    onConfigurationChanged(Configuration newConfig){
      //Handle new orientation
    }
    

    Then you don't need to confuse the user why there phone has stopped rotating during an operation.


    Also worth looking at Robospice if you want lifecyled async tasks.

提交回复
热议问题