zoukankan      html  css  js  c++  java
  • Android实现两次按下返回键退出

    1. @Override  
    2.     public boolean onKeyDown(int keyCode, KeyEvent event)   
    3.     {  
    4.                  if(keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN)  
    5.                  {  
    6.                            
    7.                          if((System.currentTimeMillis()-exitTime) > 2000)  //System.currentTimeMillis()不管何时调用,肯定大于2000  
    8.                          {  
    9.                           Toast.makeText(getApplicationContext(), "再按一次退出程序",Toast.LENGTH_SHORT).show();                                  
    10.                           exitTime = System.currentTimeMillis();  
    11.                          }  
    12.                          else  
    13.                          {  
    14.                              finish();  
    15.                              System.exit(0);  
    16.                          }  
    17.                                    
    18.                          return true;  
    19.                  }  
    20.                  return super.onKeyDown(keyCode, event);  
    21.     }  
  • 相关阅读:
    监控Nginx
    监控Tomcat
    监控memcache
    监控Redis
    14-SpringCloud Bus
    13-SpringCloud Config
    12-SpringCloud GateWay
    11-SpringCloud Hystrix
    10-SpringCloud OpenFeign
    09-SpringCloud Ribbon
  • 原文地址:https://www.cnblogs.com/yxwkf/p/5401130.html
Copyright © 2011-2022 走看看