This article describes a common Android technique code, which is mainly used to determine whether the mobile phone screen is horizontal or vertical. After judging that the screen is horizontal or vertical, you can respond to the program accordingly. The example code is just to determine whether it is a vertical screen. If the judgment is correct, it will return true, otherwise it will return false.
The specific program code is as follows:
package .; import ; import ; public class ActivityUtil { /** * Return to whether the current screen is vertical. * @param context * @return Return true if and only if the current screen is vertical, otherwise false. */ public static boolean isScreenOriatationPortrait(Context context) { return ().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT; } }