My Intention:
To listen for any user-input on any activity, irrelevant of what type of gesture or touch event it was.
My Attempted Solution
Created a custom view that's transparent, using TYPE_SYSTEM_ALERT so it's always on top, along with other Flags to (what I thought would) allow fall-through of touches to views below it.
My Issue:
The gestures do not 'fall through' to other views, including the home activity. Currently the Log fires off correctly, and I can swap apps using the recent lists, just cannot actually interact with them.
EDIT: Just found this which is very disheartening.
...this is no longer possible as of Android 4.0.3, to prevent tapjacking attacks, at least for touches on the overlay itself. An overlay can either receive touch events (and those are not forwarded along) or not receive touch events..
Any other possible solutions? I don't need to know the specifics of a touch event, just that there was an event occuring of some sort.
@Override
public void onCreate(){
super.onCreate();
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
PixelFormat.TRANSLUCENT);
gestureDetector = new GestureDetector(this, new GestureListener());
View.OnTouchListener gestureListener = new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return gestureDetector.onTouchEvent(event);
}
};
WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE);
ViewG overlayView = new ViewG(this);
wm.addView(overlayView, params);
overlayView.setOnTouchListener(gestureListener);
}
public class ViewG extends ViewGroup{
ViewG(Context context){
super(context);
}
@Override
public void onLayout(boolean bool, int a, int b, int c, int d){
}
}
public class GestureListener extends SimpleOnGestureListener implements
OnGestureListener {
public GestureListener() {
// TODO Auto-generated constructor stub
}
@Override
public boolean onDown(MotionEvent e){
Log.v("JTAG","Stop Touching Me");
return false;
}
}