I created TYPE_SYSTEM_OVERLAY and I want to record finger / touch events on this overlay using service .
Overlay works fine, but the problem is that it cannot record touch events when I try to include a GestureDetector in it. When I click on the screen, the toast msg "onDown" did not show.
would be grateful if someone would tell me where I was wrong :( I tried to implement the GestureDetector outside the OverlayView class, but also no result.
public class NUSLogService extends IntentService { OverlayView mView; @Override public void onCreate() { super.onCreate(); final WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); params.gravity = Gravity.RIGHT | Gravity.BOTTOM; params.setTitle("TouchLayer"); mView = new OverlayView(getApplicationContext()); final WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); wm.addView(mView, params); } @Override public void onDestroy() { super.onDestroy(); if(mView != null) { ((WindowManager) getSystemService(WINDOW_SERVICE)).removeView(mView ); mView = null; } }
java android service gesturedetector overlay
star
source share