我需要知道这一点,以便我可以删除退出选项。
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
mediaPlayer = MediaPlayer.create(this, R.raw.theme);
mediaPlayer.start();
mediaPlayer.setLooping(true);
}}
我需要知道这一点,以便我可以删除退出选项。
public void onWindowFocusChanged(boolean hasFocus) {
if (hasFocus) {
mediaPlayer = MediaPlayer.create(this, R.raw.theme);
mediaPlayer.start();
mediaPlayer.setLooping(true);
}}
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);
}