首页 > 安全资讯 >

Android学习之关闭应用程序的方法

11-08-10

Java代码package com.close;import java.util.LinkedList;import java.util.Stack;import android.app.Activity;public class ActivityManager {private static LinkedList<Activity> acys;private s...

 

Java代码 

package com.close;  

import java.util.LinkedList;  

import java.util.Stack;  

 

import android.app.Activity;  

 

 

 

public class ActivityManager {  

 

private static LinkedList<Activity> acys;  

private static ActivityManager instance = null;  

 

private ActivityManager (){}  

 

public static ActivityManager getInstance(){  

 

if(instance == null){  

 

instance = new ActivityManager ();  

acys = new LinkedList<Activity>();  

 

}  

 

return instance;  

 

}  

public void add(Activity acy)  

{  

acys.add(acy);  

}  

public void remove(Activity acy)  

{  

acys.remove(acy);  

}  

public void closeAll()  

{  

Activity acy;  

while(acys.size() != 0)  

{  

acy = acys.poll();  

if(!acy.isFinishing())  

acy.finish();  

}  

}  

 

}    

相关文章
最新文章
热点推荐