Funky android activity behavior when screen turns off?

后端 未结 2 1336
误落风尘
误落风尘 2021-02-15 12:41

I\'m seeing some interesting activity flow when android turns off the screen and locks the screen... my app goes through the regular flow, onCreate, onStart and onResume. Then,

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-15 13:29

    In the activity's manifest, for each application add:

    android:configChanges="orientation|keyboardHidden"
    

    This tells android you'll handle these two cases yourself - although of course you're lying: you won't do shit to handle them, but Android doesn't know that. This works great for apps/games/etc running for example in landscape mode and never change orientation.

提交回复
热议问题