Skip to content

Instantly share code, notes, and snippets.

@bapspatil
Created October 27, 2017 04:23
Show Gist options
  • Save bapspatil/2bf443e4d0af79893f6fa0faa174ec0c to your computer and use it in GitHub Desktop.
Save bapspatil/2bf443e4d0af79893f6fa0faa174ec0c to your computer and use it in GitHub Desktop.
Check the orientation of the device (landscape or portrait)
/*
** Created by bapspatil
*/
// Checks if the device is in portrait mode or not
public boolean isDeviceInPortrait() {
// Use Configuration.ORIENTATION_LANDSCAPE if you want to check for landscape orientation
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
return true;
else
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment