Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Stack;
import android.app.Activity;

public class Main {
    private static Stack<Activity> activityStack;

    public static void finishActivity(Activity activity) {
        try {
            if (activity != null) {
                try {
                    activityStack.remove(activity);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                activity.finish();
                activity = null;
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void finishActivity(Class<?> cls) {
        try {
            for (Activity activity : activityStack) {
                if (activity.getClass().equals(cls)) {
                    finishActivity(activity);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}