timer.cancel behaving different on android

Hello.  I have this code which works fine on iOS, but not on android.  What I’m trying to accomplish is a dialog pop-up if you hold your finger down on a scrollView for longer than a second.  But cancel it if the finger releases or moves before that amount of time.

local PushedtimerID function displayScrollListener( event )    local phase = event.phase    if ( "began" == phase ) then         print( event.target.id .. " pressed" )         myGlobals.touchedY = event.y         PushedtimerID = timer.performWithDelay( 1500, bookMarkCreator)       elseif ( "ended" == phase ) then         print( event.target.id .. " released" )         timer.cancel(PushedtimerID)       elseif "moved" == phase then                local dy = math.abs( ( event.y - event.yStart ) )         if dy \> 10 then           timer.cancel(PushedtimerID)         end     end    return true end  

on Android the timer.cancel never cancels the timer, every touch brings up the alert in my bookMarkCreator()

How can I get Android to cancel the timer like iOS does?

Which device are you testing this on for Android?

Because 10 pixel of touch can really be different depending on the device, if you use a set width and height in your config file.
What I mean is that the amount of space your finger has to travel along the screen to cover 10 pixel of a 480x320 screen it’s different between an iphone3Gs/4/5 (which is always the same, since only the pixel density increases, while screen size stays the same) and a samsung galaxy s3 (where it takes much more, since the 480x320 pixels gets stretched for a much bigger screen).

 

My device is an acer Iconatab 7 inch and an iPhone 4s.  But I can touch and move my finger up the whole height of the icontab screen and the timer.cancel does not cancel the timer.  I put print statements next to the timer.cancel and they print so I know the timer.cancel is being executed.

Is there another stronger android version of timer.cancel?  I need an industrial strength timer.KILLALL(*)

I’ll try your code out as soon as I can, but have you tried and see if PushedTimerID is not nil when the timer.cancel is called?
Also, might want to add a 0 at the end of the timer.performWithDelay, I know it’s optional but you never know (:

Actually 0 as the iterations for timer.performWithDelay() says keep firing it.  The default is 1 if left off.  If you want to be sure, use 1.

Rob

using a 1, still works fine on iOS but not on android.

Interesting problem.  This appears to be a bug.  I’ll let engineering know.

Rob

I used the sample Hello world app to demonstrate it, and submitted a bug.

(Case 29450) timer.cancel not same on android device

Which device are you testing this on for Android?

Because 10 pixel of touch can really be different depending on the device, if you use a set width and height in your config file.
What I mean is that the amount of space your finger has to travel along the screen to cover 10 pixel of a 480x320 screen it’s different between an iphone3Gs/4/5 (which is always the same, since only the pixel density increases, while screen size stays the same) and a samsung galaxy s3 (where it takes much more, since the 480x320 pixels gets stretched for a much bigger screen).

 

My device is an acer Iconatab 7 inch and an iPhone 4s.  But I can touch and move my finger up the whole height of the icontab screen and the timer.cancel does not cancel the timer.  I put print statements next to the timer.cancel and they print so I know the timer.cancel is being executed.

Is there another stronger android version of timer.cancel?  I need an industrial strength timer.KILLALL(*)

I’ll try your code out as soon as I can, but have you tried and see if PushedTimerID is not nil when the timer.cancel is called?
Also, might want to add a 0 at the end of the timer.performWithDelay, I know it’s optional but you never know (:

Actually 0 as the iterations for timer.performWithDelay() says keep firing it.  The default is 1 if left off.  If you want to be sure, use 1.

Rob

using a 1, still works fine on iOS but not on android.

Interesting problem.  This appears to be a bug.  I’ll let engineering know.

Rob

I used the sample Hello world app to demonstrate it, and submitted a bug.

(Case 29450) timer.cancel not same on android device