Skip to content

Instantly share code, notes, and snippets.

@JakeSteam
Created June 13, 2017 11:12
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 JakeSteam/b9503c46e65088e0e651dc75d9782979 to your computer and use it in GitHub Desktop.
Save JakeSteam/b9503c46e65088e0e651dc75d9782979 to your computer and use it in GitHub Desktop.
"Auto-detecting Device Orientation Whilst Allowing User to Override" for GameDevAlgorithms.com
@Override
protected void onResume() {
super.onResume();
//noinspection ResourceType
setRequestedOrientation(Setting.get(Enums.Setting.Orientation).getIntValue());
}
public final static int ORIENTATION_AUTO = 4;
public final static int ORIENTATION_LANDSCAPE = 6;
public final static int ORIENTATION_PORTRAIT = 7;
private int getOrientationValue(int position) {
switch (position) {
case 1: return Constants.ORIENTATION_LANDSCAPE;
case 2: return Constants.ORIENTATION_PORTRAIT;
default: return Constants.ORIENTATION_AUTO;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment