I need to record all touch points in an activity so I have added an overlay view in window manager and set the touch listener on the overlay view and I am getting all touch point but I am facing two issues after adding the overlay
- I can open the options menu but not able to select any menu item
- AlertDialog.show() stopped showing the alertbox I can get all touch points by overriding onTouchEvent method inside activity but app requirement does not permit that.
It will be great if any one can help me in this or share some link which explains about WindowManager, window and DecorView etc . here is my code, please let me know if more information is required.
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
| WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
WindowManager wm = (WindowManager) activityContext
.getSystemService(Context.WINDOW_SERVICE);
View mView = new View(activityContext);
wm.addView(mView, params);
mView.setOnTouchListener(new OnTouchListener() {
@Overrideenter code here
public boolean onTouch(View v, MotionEvent event) {
Log.d("touch", "event occured");
activity.getWindow().superDispatchTouchEvent(event);
// or
// activity.dispatchTouchEvent(event);
return false;
}
});