Have you tried using MotionEvent.ACTION_CANCEL in the double-tap listener?

GestureDetector has code to reset its internal state in response to this:

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/view/GestureDetector.java#L594

I'm thinking you'd need post a handler message to self to get out of the
current stack state when onDoubleTap is called, and then in response to
that message, use ACTION_CANCEL to reset the gesture listener and then
start the activity.

-- Kostya

20 января 2012 г. 17:37 пользователь skink <[email protected]> написал:

> hi,
>
> i'm using GestureDetector to detect double tup actions and having a
> little problem when trying to startActivity() inside onDoubleTap
> listener.
>
> namely i have observed when onDoubleTap is empty i see the following:
>
> D/GestureActivity(  987): onTouchEvent action=0
> D/GestureActivity(  987): onTouchEvent action=1
> D/GestureActivity(  987): onTouchEvent action=0
> D/GestureActivity(  987): onDoubleTap
> D/GestureActivity(  987): onTouchEvent action=1
>
> here action == 0 for ACTION_DOWN, while action == 1 for ACTION_UP
>
> as you can see onDoubleTap is being called after second tups's
> ACTION_DOWN and before its ACTION_UP, strange but OK
>
> but when i call startActivity() in onDoubleTap listener i see:
>
> D/GestureActivity( 1019): onTouchEvent action=0
> D/GestureActivity( 1019): onTouchEvent action=1
> D/GestureActivity( 1019): onTouchEvent action=0
> D/GestureActivity( 1019): onDoubleTap
> D/GestureActivity( 1019): onPause
>
> as you can see there is missing second ACTION_UP (i think it's because
> my main activity is paused and doesn't handle touch events) and when i
> return back to my main activity GestureDetector is somehow mislead and
> behaves a bit strange
>
> in the end i used onDoubleTapEvent (instead of onDoubleTap) like this:
> public boolean onDoubleTapEvent(MotionEvent e) {
>        if (e.getAction() == MotionEvent.ACTION_UP) {
>                // start activity here
>        }
> }
>
> and it works OK but i'm still not sure if it's a good solution
>
> any ideas how to use onDoubleTap in my scenario?
>
> pskink
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to