优缺点 不多说了。。
下面是个 实现。
private static Stack<Activity> s_activitiesStack = new Stack<Activity>(); public final static void pushActivity(Activity activity) { if (IConfig.MANAGE_ACTIVITYSTACK_MANUALLY) { if (IConfig.DEBUG_ON) Log.v(TAG, "Push activity:" + activity.getClass().getName()); s_activitiesStack.push(activity); } } public final static void popActivity() { if (IConfig.MANAGE_ACTIVITYSTACK_MANUALLY) { if (!s_activitiesStack.isEmpty()) { s_activitiesStack.pop(); } } } public final static Activity getTopActivity() { if (IConfig.MANAGE_ACTIVITYSTACK_MANUALLY) { if (!s_activitiesStack.isEmpty()) { return s_activitiesStack.peek(); } } return null; } public final static void backToActivity(Class activity) { if (IConfig.MANAGE_ACTIVITYSTACK_MANUALLY) { while (!s_activitiesStack.isEmpty()) { Activity a = s_activitiesStack.peek(); if (a.getClass().equals(activity) || a.getClass().equals(HomeActivity.class)) { break; } if (IConfig.DEBUG_ON) Debug.u(TAG, "a.getClass():" + a.getClass().toString()); if(a instanceof HotelDetailsActivity){ ((HotelDetailsActivity)a).back(); }else{ a.finish(); Utils.popActivity(); } } } } public final static void exit(Context context, Class luanchActivity) { Intent intent = new Intent(); intent.setClass(context, luanchActivity); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(AppConstants.BUNDLEKEY_EXIT, true); context.startActivity(intent); }