1. 程式人生 > >移動開發---點選2次返回退出

移動開發---點選2次返回退出

 private long Current = 0;
 public void onBackPressed() {
        if (System.currentTimeMillis() - Current > 2000) {
            Current = System.currentTimeMillis();
            Toast.makeText(this, "Press again to exit", Toast.LENGTH_SHORT).show();
        } else {
            finish();
            System.exit(0);
        }
    }