Java tutorial
//package com.java2s; /* ActivityHelper.java * See the file "LICENSE.md" for the full license governing this code. */ import android.annotation.TargetApi; import android.app.Activity; import android.os.Build; import android.view.Window; public class Main { /** * Request the ActionBar window feature if we are on a supported Android * version. This should be called before the activity's setContentView. * * @param activity */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void addActionBarIfSupported(Activity activity) { if (actionBarSupported()) { activity.requestWindowFeature(Window.FEATURE_ACTION_BAR); } } private static boolean actionBarSupported() { return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; } }