Android中如何一次性finish掉以前打开的所有的activity

版权声明:欢迎转载,请注明文章出处,个人博客:www.qiuchengjia.cn 联系邮箱 qiuqiuchengjia@163.com https://blog.csdn.net/qq_26891045/article/details/52517430
public class ActivityManagerApplication extends Application {  

    private static Map<String,Activity> destoryMap = new HashMap<>();  

    private ActivityManagerApplication() {  
    }  

    /** 
     * 添加到销毁队列 
     * 
     * @param activity 要销毁的activity 
     */  

    public static void addDestoryActivity(Activity activity,String activityName) {  
        destoryMap.put(activityName,activity);  
    }  
    /** 
    *销毁指定Activity 
    */  
    public static void destoryActivity(String activityName) {  
       Set<String> keySet=destoryMap.keySet();  
        for (String key:keySet){  
            destoryMap.get(key).finish();  
        }  
    }  
}  
阅读更多

没有更多推荐了,返回首页