Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.Intent; import android.os.Bundle; public class Main { public static void openActivity(Activity activity, Intent intent, Bundle options) { if (null == activity || null == intent) return; activity.startActivity(intent, options); } public static void openActivity(Activity activity, Intent intent) { if (null == activity || null == intent) return; activity.startActivity(intent); } public static void openActivity(Activity activity, Class<?> pClass) { openActivity(activity, pClass, null, -1, -1, -1); } public static void openActivity(Activity activity, Class<?> pClass, Bundle pBundle) { openActivity(activity, pClass, pBundle, -1, -1, -1); } public static void openActivity(Activity activity, Class<?> pClass, Bundle pBundle, int requestCode) { openActivity(activity, pClass, pBundle, requestCode, -1, -1); } public static void openActivity(Activity activity, Class<?> pClass, int enterAnim, int exitAnim) { openActivity(activity, pClass, null, -1, enterAnim, exitAnim); } public static void openActivity(Activity activity, Class<?> pClass, int requestCode) { openActivity(activity, pClass, null, requestCode, -1, -1); } public static void openActivity(Activity activity, String pAction, int requestCode) { openActivity(activity, pAction, null, requestCode); } public static void openActivity(Activity activity, Class<?> pClass, String pAction, Bundle pBundle, int requestCode) { if (null == activity) return; Intent intent = new Intent(pAction); intent.setClass(activity, pClass); if (pBundle != null) { intent.putExtras(pBundle); } if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } } public static void openActivity(Activity activity, String pAction, Bundle pBundle, int requestCode) { if (null == activity) return; Intent intent = new Intent(pAction); if (pBundle != null) { intent.putExtras(pBundle); } if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } } public static void openActivity(Activity activity, Intent intent, int requestCode) { openActivity(activity, intent, requestCode, -1, -1); } public static void openActivity(Activity activity, Intent intent, int requestCode, int enterAnim, int exitAnim) { if (null == activity) return; if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } if (enterAnim > 0 && exitAnim > 0) { activity.overridePendingTransition(enterAnim, exitAnim); } } public static void openActivity(Activity activity, Class<?> pClass, int requestCode, int enterAnim, int exitAnim) { openActivity(activity, pClass, null, requestCode, enterAnim, exitAnim); } public static void openActivity(Activity activity, Class<?> pClass, Bundle pBundle, int requestCode, int enterAnim, int exitAnim) { if (null == activity) return; Intent intent = new Intent(activity, pClass); if (pBundle != null) { intent.putExtras(pBundle); } if (requestCode < 0) { activity.startActivity(intent); } else { activity.startActivityForResult(intent, requestCode); } if (enterAnim > 0 && exitAnim > 0) { activity.overridePendingTransition(enterAnim, exitAnim); } } }