Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; import android.content.Context; import android.content.Intent; public class Main { public static void gotoActivity(Context ctx, Class<?> c) { gotoActivity(ctx, c, true); } public static void gotoActivity(Context ctx, Class<?> c, boolean close) { Intent intent = new Intent(ctx, c); ctx.startActivity(intent); if (close) { ((Activity) ctx).finish(); } } public static void gotoActivity(Context ctx, Class<?> c, String s, boolean b) { Intent intent = new Intent(ctx, c); intent.putExtra(s, b); ctx.startActivity(intent); ((Activity) ctx).finish(); } public static void gotoActivity(Context ctx, Class<?> c, String s, boolean b, int flag) { Intent intent = new Intent(ctx, c); intent.putExtra(s, b); intent.setFlags(flag); ctx.startActivity(intent); ((Activity) ctx).finish(); } }