android 双击退出

boolean isExit = false;
@Override
public void onBackPressed() {
    if (!isExit) {
        Toast.makeText(this,"再次点击退出",Toast.LENGTH_LONG).show();
        new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    isExit = true;
                    Thread.sleep(2000);
                    isExit = false;
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
        return;
    }
    super.onBackPressed();
}
阅读更多

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