Read the direction attribute from the local configuration, with three values in total
LocalConfiguration.current.orientation
The corresponding attribute value is in android.content.res.Configuration
the class
public static final int ORIENTATION_UNDEFINED = 0; // 未知
public static final int ORIENTATION_PORTRAIT = 1; // 竖屏
public static final int ORIENTATION_LANDSCAPE = 2; // 横屏
LocalConfiguration.current
It contains a lot of configurations, which can be obtained from here