I would like to create a photo/video capture application.
I have created a CaptureView
class which extends SurfaceView
and placed it in the main form.
The main form's activity has onCreateOptionsMenu()
method which creates a menu. The menu worked fine but then I tried to implement a method onKeyDown
:
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(event.getAction() == KeyEvent.ACTION_DOWN) {
switch(keyCode) {
case KeyEvent.KEYCODE_CAMERA:
videoPreview.TakePicture();
return true;
}
}
return super.onKeyDown(keyCode, event);
}
The menu doesn't appear anymore and the method doesn't catch onKeyDown event.
Does anyone know what could be the reason for this issue?
I had a similar problem and solved it by adding
this.requestFocus();
this.setFocusableInTouchMode(true);
in the constructor of my SurfaceView subclass.