WEB开发网
开发学院手机开发Android 开发 android Activity管理 阅读

android Activity管理

 2010-08-14 00:37:00 来源:WEB开发网   
核心提示:import java.util.Stack;import android.app.Activity;public class ScreenManager {private static Stack activityStack;private static ScreenManager instance;private

import java.util.Stack;

import android.app.Activity;

public class ScreenManager {

private static Stack activityStack;

private static ScreenManager instance;

private ScreenManager(){

}

public static ScreenManager getScreenManager(){

if(instance==null){

instance=new ScreenManager();

}

return instance;

}

public void popActivity(){

Activity activity=activityStack.lastElement();

if(activity!=null){

activity.finish();

activity=null;

}

}

public void popActivity(Activity activity){

if(activity!=null){

activity.finish();

activityStack.remove(activity);

activity=null;

}

}

public Activity currentActivity(){

Activity activity=activityStack.lastElement();

return activity;

}

public void pushActivity(Activity activity){

if(activityStack==null){

activityStack=new Stack();

}

activityStack.add(activity);

}

public void popAllActivityExceptOne(Class cls){

while(true){

Activity activity=currentActivity();

if(activity==null){

break;

}

if(activity.getClass().equals(cls) ){

break;

}

popActivity(activity);

}

}

}

以上是转载的,自己做一个mark

Tags:android Activity 管理

编辑录入:coldstar [复制链接] [打 印]
赞助商链接