In my application, I have put a button that plays its own sound by picking a random button sound source from the raw directory.
But when the button is clicked, the default PHONE BUTTON SOUND plays first and then my custom button sound.
How can I disable the default 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)]);
}
all i think you should need to do is:
However this may be global, you may need to make your own Button class and set this.setSoundEffectsEnabled(false).