Search code examples
androidandroid-activitytouch

Detect when my activity has been touched


I would like to do a simple thing but I haven't succeeded so far : I would like to know when the user touched anywhere in the activity.

The thing is that when I do getContentView().setOnTouchListener(...);, the touch event gets consumed by the child views, and it will only be fired if I touch outside of any view in my activity.

Is there a solution which doesn't involve extending the content view class ?

Thanks !


Solution

  • override

    dispatchTouchEvent(MotionEvent ev) 
    

    method in activity