Java tutorial
//package com.java2s; import java.util.ArrayList; import android.app.Activity; public class Main { public static ArrayList<Activity> arrayList = new ArrayList<Activity>(); public static void finishActivity() { Activity activity = null; int length = arrayList.size() - 1; for (int i = length; i >= 0; i--) { activity = arrayList.get(i); if (activity != null) { activity.finish(); arrayList.remove(i); } } } }