Enable / disable orientation in activity

1 vote · 1 comment

Lock / enable Orientation in any activity

raw ·
copy
· download
public void setOrientation(boolean status) { if (status) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED); } else { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } }
Add a comment

1 Comment

In AndroidManifest.xml just add android:screenOrientation="portrait"

Ex:

<activity android:name=".MyActivity" android:label="@string/app_name" android:screenOrientation="portrait">

Reply · May 26, 2014, 7:26 a.m.