Skip to content

Instantly share code, notes, and snippets.

@matthewmorrone
Created November 12, 2019 17:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matthewmorrone/e1d620396e750ce68f1f22da5bf9bd82 to your computer and use it in GitHub Desktop.
Save matthewmorrone/e1d620396e750ce68f1f22da5bf9bd82 to your computer and use it in GitHub Desktop.
public void setOrientation(boolean status) {
if (status) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
}
}
// In AndroidManifest.xml just add android:screenOrientation="portrait"
// <activity android:name=".MyActivity" android:label="@string/app_name" android:screenOrientation="portrait">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment