Android activity restarted at orientation change even with configChanges set

后端 未结 2 1099
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 16:25

I have an Android library project and the main application that uses this library project. The manifest file of the main application looks as follows:



        
相关标签:
2条回答
  • 2021-01-21 17:21

    You need to add keyboard|keyboardHidden to the android:configChanges attribute. Certainly on the emulator (and on certain devices, I think), when you change orientations the keyboard state also changes. This is also needed to prevent double-restarts of your activity when you don't have it handling orientation changes.

    0 讨论(0)
  • 2021-01-21 17:23

    If you use abs, it is a limitation, and you can't solve it. But you don't use that library, so give this in the activity tag in manifest file

     android:configChanges="keyboard|keyboardHidden|orientation"
    

    remove that

     android:screenOrientation="sensor"
    
    0 讨论(0)
提交回复
热议问题