Java tutorial
//package com.java2s; import android.app.ActionBar; import android.app.Activity; import android.content.pm.ActivityInfo; import android.view.WindowManager; import android.view.WindowManager.LayoutParams; public class Main { public static void initialize(Activity activity, int layout) { // Do all sorts of common task for your activities here including: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); activity.setContentView(layout); activity.getWindow().addFlags(LayoutParams.FLAG_KEEP_SCREEN_ON); activity.getActionBar().setDisplayOptions( ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM); activity.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); } }