package com.spoon.tools; import java.util.ArrayList; import java.util.List; import java.util.Map; import android.app.Activity; import android.content.Context; import android.content.Intent; public class XrActivityCollector { public static List<Activity> activities = new ArrayList<Activity>(); /** * 添加活动 */ public static void addActivity(Activity activity) { activities.add(activity); } /** * 移除活动 */ public static void removeActivity(Activity activity) { activities.remove(activity); } /** * 销毁全部活动 */ public static void finishAll() { for (Activity activity : activities) { if (!activity.isFinishing()) { activity.finish(); } } } /** * 活动的启动 && !datas.equals(null) */ public static void actionStart(Context context, Class<?> cls, Map<String, String> datas) { Intent intent = new Intent(context, cls); if (datas != null) { for (Map.Entry<String, String> entry : datas.entrySet()) { intent.putExtra(entry.getKey(), entry.getValue()); } } context.startActivity(intent); } }