0

我需要知道这一点,以便我可以删除退出选项。

 public void onWindowFocusChanged(boolean hasFocus) { 
if (hasFocus) { 
 mediaPlayer = MediaPlayer.create(this, R.raw.theme); 
 mediaPlayer.start();
    mediaPlayer.setLooping(true);

}}
4

1 回答 1

0
public void onWindowFocusChanged(boolean hasFocus) { 
if (hasFocus) { 
 Static mediaPlayer mp = MediaPlayer.create(this, R.raw.theme); 
mp.start();
mp.setLooping(true);

}}

使用它来覆盖主键。

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_HOME)) {
    Toast.makeText(this, "You pressed the home button!", Toast.LENGTH_LONG).show();                     
    mp.pause();
    return true;
}
return super.onKeyDown(keyCode, event);
}
于 2012-12-23T14:42:02.347 回答