2

In my activity there are ActionBar,ListView,ContextMenu,Menu.

I wanted to capture the user interaction with my activity(means when ever user touch in my activity i wanted to show a toast).I use this

@Override
    public void onUserInteraction() 
    {

            Toast.makeText(this, "Hello",Toast.LENGTH_LONG).show();
    }

This method working with in screen but problem with this method its not working with

Menus,ContextMenu(ListView).

Working Scenario:- 1-This is working first time when i touch the screen Every where in activity (ActionBar,ListView).

2-After clicking the Menus first time this method is calling and if the Menu is related to activity (if i want to go on next activity ) it is working fine but there is a Menu REFRESH in same activity ,i do not know why this method not calling on clicking on REFRESH.

3- The same problem with ContextMenu (comes after long press on ListView)

I tried GestureDetecter also.

There is any particular method or anything in android ,which can detect the user touch every time in menus,contextmenu,list,screen or every where.

Lots of Thanks

Monty
  • 3,205
  • 8
  • 36
  • 61

1 Answers1

2

I think you can override dispatchTouchEvent() in your Activity to get the result you want

something like this:

@Override
public boolean dispatchTouchEvent(MotionEvent me){
  //do something
  return super.dispatchTouchEvent(me);
}

See the activity docs for more

Also I think it is worth noting that your users may find it quite annoying if you are displaying a toast any time they touch anything on the screen.

FoamyGuy
  • 46,603
  • 18
  • 125
  • 156