In my Custom IME
I want to play a BEEP
sound on the key when user presses that.
I found how-do-i-access-androids-default-beep-sound , and in my SoftKeyboard.java
class I added that code in :
public void onKey(int primaryCode, int[] keyCodes) {
// play sound on keypress
try {
MediaPlayer mMediaPlayer = MediaPlayer.create(context, R.raw.beep);
mMediaPlayer.prepare();
mMediaPlayer.start();
} catch (Exception e) {e.printStackTrace();}
}
BUT that does not work, any ideas why?