[英]android app designed for portrait mode displayed in landscape when resuming
I have designed an Android app to be displayed in portrait mode only (android:screenOrientation="sensorPortrait"). 我设计的Android应用程序只能以纵向模式显示(android:screenOrientation =“sensorPortrait”)。 It works fine except in one case:
除一例外,它工作正常:
==> the first "frame" of my app is displayed in landscape mode and then it is rotated to portrait mode, which means onDestroy() is called and so my entered data is lost. ==>我的应用程序的第一个“框架”以横向模式显示,然后旋转到纵向模式,这意味着调用了onDestroy(),因此输入的数据将丢失。
The tablet is a tab S2 8", with Android 7.0 平板电脑是一个标签S2 8“,与Android 7.0
Why is my app first displayed in landscape mode? 为什么我的应用首先以横向模式显示? Is there a way to avoid this behavior (I would like t avoid managing onSaveInstanceState()/onRestoreInstanceState() just because of this case)?
有没有办法避免这种行为(我想避免管理onSaveInstanceState()/ onRestoreInstanceState()只是因为这种情况)?
解决方案是实现ViewModel。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.