如何退出启动了多个activity
1个回答
展开全部
public class ExitApplication extends Application { private List activityList = new LinkedList(); private static ExitApplication instance; private ExitApplication() { } // 单例模式中获取唯一的ExitApplication实例 public static ExitApplication getInstance() { if (null == instance) { instance = new ExitApplication(); } return instance; } // 添加Activity到容器中 public void addActivity(Activity activity) { activityList.add(activity); } // 遍历所有Activity并finish public void exit() { for (Activity activity : activityList) { activity.finish(); } System.exit(0); }将ExitApplication.getInstance().addActivity(this);添加到要退出的活动中。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询