android 专为纵向模式设计的应用在恢复时横向显示
android app designed for portrait mode displayed in landscape when resuming
我设计了一个 Android 应用程序,仅在纵向模式下显示 (android:screenOrientation="sensorPortrait")。它工作正常,除了一种情况:
- 以纵向模式握住平板电脑并启动应用程序
- 输入一些数据
- 关闭平板电脑
- 将平板电脑旋转到横向模式
- 打开平板电脑
==> 我的应用程序的第一个 "frame" 以横向模式显示,然后旋转到纵向模式,这意味着 onDestroy() 被调用,所以我输入的数据丢失了。
平板电脑是标签 S2 8",Android 7.0
为什么我的应用首先以横向模式显示?
有没有办法避免这种行为(我不想因为这种情况而避免管理 onSaveInstanceState()/onRestoreInstanceState())?
解决方案是实现 ViewModel。
我设计了一个 Android 应用程序,仅在纵向模式下显示 (android:screenOrientation="sensorPortrait")。它工作正常,除了一种情况:
- 以纵向模式握住平板电脑并启动应用程序
- 输入一些数据
- 关闭平板电脑
- 将平板电脑旋转到横向模式
- 打开平板电脑
==> 我的应用程序的第一个 "frame" 以横向模式显示,然后旋转到纵向模式,这意味着 onDestroy() 被调用,所以我输入的数据丢失了。
平板电脑是标签 S2 8",Android 7.0
为什么我的应用首先以横向模式显示? 有没有办法避免这种行为(我不想因为这种情况而避免管理 onSaveInstanceState()/onRestoreInstanceState())?
解决方案是实现 ViewModel。