editor_ View does not support functions such as displaying and writing after screen rotation. Is there any way to be compatible with screen rotation? From vertical screen to landscape screen
I am not sure to understand.
Indeed, if running our Demo sample, by default screen rotate works fine. With our getStarted sample, simply setting the screenOrientation to sensor will allow screen rotation:
<application android:name=".IInkApplication" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> <activity android:name=".MainActivity" android:launchMode="singleTask" android:screenOrientation="sensor" android:exported="true"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> If this doesn't help, please describe the behavior you are facing. Best regards,
In the official example, the Demo example can indeed rotate the screen, but GetStarted cannot. Because I am not very familiar with Kotlin and am using JAVA There are still doubts in many places. I tried to read the demo and through one by one investigation, I found that the override fun on Destroy() method affects rotating the screen. If the statement in this method is missing, the rotating screen application will crash directly after starting the application. So I tried to understand the viewModel. setEditor (null) in the override fun on Destroy() method and found that it consists of several layers of structure.Due to Kotlin's unfamiliarity, reading is very difficult and slow. Is there any example of a JAVA version for me to refer to and implement?
Indeed, screen rotation will cause the activity to shutdown and restart, and the
onDestroy() functions will be called: https://developer.android.com/codelabs/basic-android-kotlin-compose-activity-lifecycle?hl=en#4
On my side, I simply tried to set the screenOrientation to sensor, and did not get any crash with the default getStarted sample: android:screenOrientation="sensor"
Of course, as the onDestroy() sets the editor to null and we do not save the content package and create it again in the onStart(), the content of the screen is not saved or restored. You shall then implement this by yourself, but it shall not be a difficulty.