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; public class Main { /** * Overrides whatever theme the activity currently has with either * Theme_Holo_Light or Theme_Light, depending on OS support. * * @param activity * @param useApplicationTheme */ @TargetApi(Build.VERSION_CODES.HONEYCOMB) public static void setActivityTheme(Activity activity, boolean useApplicationTheme) { if (useApplicationTheme && 0 != activity.getApplicationInfo().theme) { activity.setTheme(activity.getApplicationInfo().theme); } else if (holoSupported()) { activity.setTheme(android.R.style.Theme_Holo_Light); } else { activity.setTheme(android.R.style.Theme_Light); } } public static boolean holoSupported() { return android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB; } }