在我的应用程序中,我通过从raw
目录中选取一个随机按钮声源来播放自己的声音。Android;在默认按钮声音后播放按钮声音
但是,当按钮被点击时,默认的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)]);
}
我在哪里可以在我的代码中调用此方法?我只想禁用默认的电话按键声音,并保持我自己的应用程序按键声音正常运行。 – jmishra