Right now all I am trying to do is detect when the screen is pressed and then display a log message to confirm it happened. My code so far is modified off of the CameraPreview sample code (it will eventually take a picture) so the bulk of the code is in a class that extends SurfaceView. API for the example code from the SDK is 7.
To make sure that each view correctly receives the touch events intended for it, override the onInterceptTouchEvent() method. Refer to the following related resources: Input Events API Guide. Sensors Overview.
Add the touch point handlers to the specific target element (rather than the entire document or nodes higher up in the document tree). Add touchmove , touchend and touchcancel event handlers within the touchstart . The target touch element or node should be large enough to accommodate a finger touch.
To make sure that each view correctly receives the touch events intended for it, override the onInterceptTouchEvent() method.
Try code below to detect touch events.
mView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
//show dialog here
return false;
}
});
To show dialog use Activity method showDialog(int). You have to implement onCreateDialog(). See documentation for details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With