Java tutorial
//package com.java2s; import android.app.Activity; import android.content.Intent; public class Main { public static void CloseActivity(Activity activity, Class<?> class1) { Intent intent = new Intent(activity, class1); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); activity.startActivity(intent); } }