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[] name, String[] value) { // sendtoService(ctx, Constant.ACT_PLAY_SOUND, 0, String.valueOf(Constant.SOUND_FLINGED)); Intent intent = new Intent(ctx, c); if (name != null) for (int i = 0; i < name.length; i++) intent.putExtra(name[i], value[i]); ctx.startActivity(intent); ((Activity) ctx).finish(); } public static void gotoActivity(Context ctx, Class<?> c, String key, String value) { Intent intent = new Intent(ctx, c); intent.putExtra(key, value); ctx.startActivity(intent); } 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(); } }