Android 完全退出

[一篮饭特稀原创,转载请注明出自http://www.cnblogs.com/wanghafan/archive/2012/08/24/2654313.html]

解决退出依旧返回上一页问题!

1.在Common.java中

public class Common
{
    public static List<Activity> activityList = new ArrayList<Activity>();
    public static void CloseAllActivity(Context context)
    {
        for (int i = 0; i < activityList.size(); i++)
            if (null != activityList.get(i))
                activityList.get(i).finish();
        System.exit(0);
    }
}

 2.在Activity.java中

public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Common.activityList.add(this);
}

3.关闭按钮中

Common.CloseAllActivity(this);
posted @ 2012-08-24 15:31  一篮饭特稀  阅读(186)  评论(0编辑  收藏  举报