Swipe gesture detect via service in android -
how detect swipe event via service sidebar (on android market).... try service layout therefore can able detect swipe gesture main problem layout view have it's own area therefore bad idea detecting swipe event service view...
public class gestureswipe extends service { private static final int swipe_min_distance =5; private static final int swipe_threshold_velocity = 10; @suppresswarnings("deprecation") final gesturedetector gt = new gesturedetector(new gesturelistener()); private windowmanager wm; private linearlayout beam; @override public void oncreate() { super.oncreate(); beam = new linearlayout(this); layoutparams lp = new layoutparams(10,layoutparams.match_parent); beam.setlayoutparams(lp); wm = (windowmanager) getsystemservice(window_service); windowmanager.layoutparams mparams = new windowmanager.layoutparams( 10,windowmanager.layoutparams.match_parent, windowmanager.layoutparams.type_phone, windowmanager.layoutparams.flag_not_focusable, pixelformat.translucent); mparams.gravity = gravity.left; //beam.setbackgroundcolor(color.red); beam.setontouchlistener(new ontouchlistener() { public boolean ontouch(final view view, final motionevent event) { gt.ontouchevent(event); return true; } }); wm.addview(beam, mparams); } @override public ibinder onbind(intent arg0) { return null; } private class gesturelistener extends simpleongesturelistener { @override public boolean onfling(motionevent e1, motionevent e2, float velocityx, float velocityy) { if (e1.getx() - e2.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { return false; // right left } else if (e2.getx() - e1.getx() > swipe_min_distance && math.abs(velocityx) > swipe_threshold_velocity) { return false; // left right } if (e1.gety() - e2.gety() > swipe_min_distance && math.abs(velocityy) > swipe_threshold_velocity) { return false; // bottom top } else if (e2.gety() - e1.gety() > swipe_min_distance && math.abs(velocityy) > swipe_threshold_velocity) { return false; // top bottom } return false; } } }
is possible view detect gesture , ignore touch event , behave transparent touch otherside..... please tell me how can ? there other idea doing this??? programmer..
Comments
Post a Comment