Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set activity to specific orientation before it start

Tags:

android

Is there a way I can start activity in a specific orientation (programmatically) without having it to be recreated again? Right now if I call setRequestedOrientation from the the OnCreate and the orientation is different than the current then the activity is destoryed and restarted again.

Thank you

like image 670
Snake Avatar asked Oct 01 '22 04:10

Snake


1 Answers

For me solution was to lock orientation of Activity

android:screenOrientation="locked"

, and now it depends only on setRequestedOrientation():

   <activity android:name=".SomeActivity"
      android:label="@string/app_name"
      android:screenOrientation="locked">

No restarting anymore.

like image 143
user3098756 Avatar answered Oct 13 '22 12:10

user3098756