安卓返回键退出程序

public static List activityList = new LinkedList();
在每个页面添加到这个list
activityList.add(this);
//返回键退出程序
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK
            && event.getAction() == KeyEvent.ACTION_DOWN) {
        for (Activity activity : ParameterSetActivity.activityList) {
            activity.finish();
        }
        System.exit(0);
        return true;
    }
    return super.onKeyDown(keyCode, event);
}

你可能感兴趣的:(android)