13、Android重写系统返回键

1、方法一

@Override

 public boolean onKeyDown(int keyCode, KeyEvent event) {

           if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) {

                     //TODO something

                    return   true;

              }

              return  super.onKeyDown(keyCode, event);

 }

2、方法二

@Override

 public  void  onBackPressed() {

          //TODO something

         super.onBackPressed();

 }

 

你可能感兴趣的:(android,android开胃小菜)