how lock horizontal orientation android

Java
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
Source

Also in Java: