I have a button, and i am trying to fire two actions in one button.
to call the method takeVideo
on button long press. and on button press i want to call the method imageCapture
.
the below code is working for long press. but i am not able to detect the button press to call only the imageCapture
method.
takePhotoBtn.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
long down;
int action = motionEvent.getAction();
if (action == MotionEvent.ACTION_BUTTON_PRESS) {
imageCapture();
return true;
}
if (action == MotionEvent.ACTION_DOWN) {
takeVideo();
timer.start();
return true;
} else if (action == MotionEvent.ACTION_UP) {
takeVideo();
timer.cancel();
return true;
}
return false;
}
});
EDIT
i am not using OnLongClickListener
and OnClickListener
.
i want to perform other actions on MotionEvent.ACTION_UP
so i am trying to solve my problem using setOnTouchListener
in this case