im trying to create and app with a recording an audio and playing it. it currently has 2 buttons - 1 for recording and 1 for playing the last recorded sound. when im pressing the recording button it works perfect.
then, i tried to make it record by capturing the volume up button click.(wanted to make it record as long as the button is pressed).
when i try to record from the volume up button it throws me and IllegalStateException.
this is how i handle the click action on the volume up:
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_VOLUME_UP:
player.startRecording();
return true;
}
return super.onKeyDown(keyCode, event);
}
public boolean onKeyUp(int keyCode, KeyEvent event) {
switch(keyCode){
case KeyEvent.KEYCODE_VOLUME_UP:
player.stopRecording();
return true;
}
return super.onKeyUp(keyCode, event);
}
thx in advance and sorry for the bad english
0 comments:
Post a Comment