I am using the following line of code for each of开发者_如何学Go my activities in order to force the screen orientation to portrait mode:
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
It works ok unless I put the device in landscape mode before launching the app. In this case, the activity closes suddenly.
Any idea on how to manage this case?
you need to use android:screenOrientation = "portrait"
in your activity tag.
精彩评论