今天学习broadcast的进阶用法。
准备一个关闭所有Activity的ActivityCollector ,这里之前用前面Activity提供的那个!
public class ActivityCollector {
private 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();
}
}
}
}