What code that perceives and returns the screen orientation?
If the cell phone is standing or lying down?
What code that perceives and returns the screen orientation?
If the cell phone is standing or lying down?
Configuration configuration = getResources().getConfiguration();
if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE){
//...
}else{
//...
}
In this example, it checks if the position of the screen is landscape if not, it can only be in portrait (standing)!
Pretty simple.
To check for guidance, just use this code:
getResources().getConfiguration().orientation
There is a return for each type of guidance, which you can check below:
ORIENTATION_UNDEFINED
= 0 ORIENTATION_PORTRAIT
= 1 ORIENTATION_LANDSCAPE
= 2 ORIENTATION_SQUARE
= 3