Here you can find the source of setOrientation(Activity activity, String orientation)
static public void setOrientation(Activity activity, String orientation)
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.content.pm.ActivityInfo; import android.util.Log; public class Main { private static final String TAG = "Helper"; static public void setOrientation(Activity activity, String orientation) { if (orientation.equals("LANDSCAPE")) { Log.i(TAG, "Forcing orientation to landscape"); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals("PORTRAIT")) { Log.i(TAG, "Forcing orientation to portrait"); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals("AUTOMATIC")) { Log.i(TAG, "Automatic orientation"); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else {/*from w w w . j a va2 s . co m*/ Log.i(TAG, "No orientation change"); } } }