9

OnBack按键我想最小化应用程序,我该怎么做???

public boolean onKeyDown(int keyCode, KeyEvent event) {

   if (keyCode == KeyEvent.KEYCODE_BACK) {

           //Here i want to put minimize code.. pls give me this statement

       return true;
   }
   return super.onKeyDown(keyCode, event);

}

谢谢

4

1 回答 1

31
public boolean onKeyDown(int keyCode, KeyEvent event)  
    {
         if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0)
         {
            this.moveTaskToBack(true);
            return true;
         }
        return super.onKeyDown(keyCode, event);
    }

这会将活动发送到后台。请参阅文档以获取更多参考。

于 2011-07-08T05:32:31.090 回答