raw
在我的应用程序中,我放置了一个按钮,通过从目录中选择一个随机按钮声源来播放自己的声音 。
但是当点击按钮时,默认的 PHONE BUTTON SOUND 首先播放,然后是我的自定义按钮声音。
如何禁用默认的电话按键声音?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.menu);
//will fetch a random button sound and load it in this variable.
ImageButton amazingPicsButton = (ImageButton) findViewById(R.id.amazingPics);
amazingPicsButton.getBackground().setAlpha(2);
amazingPicsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent("com.jasfiddle.AmazingInterface.AMAZINGPICS"));
//create random sound
amazingPicsSound = createRandButSound();
amazingPicsSound.start();
}
});
}
private MediaPlayer createRandButSound(){
return MediaPlayer.create(this, buttonSounds[r.nextInt(buttonSounds.length)]);
}