views:

674

answers:

4

Android supports an event onLongPress. The question I have is 'how long' (in milliseconds) is the 'press' to trigger the event?

+2  A: 

You can use the getLongPressTimeout method in android.view.ViewConfiguration to programmatically determine this value.

See the docs for details.

Roman Nurik
A: 

Hmmm ... I was hoping to get the accumulative time. As far as I can tell, getLongPressTimeout(), is the component time that is added to when event-press is determined to be start, plus TAP_TIMEOUT, plus ??? and then 1000ms if in the web browser.

I have calculated it to be 1650ms but I would like to have some confirmation of the resultant value. The reason is that I need something that is not integrated with the SDK to predict the long-hold.

I believe the value from getLongPressTimeout is 500ms, but the gesture clearly takes longer -- closer to 2 seconds.

mobibob
A: 

View (and therefore most of its subclasses) uses getLongPressTimeout. Perhaps the default timeout was not sufficient in the browser.

James
+3  A: 

The standard long press time is what is returned by getLongPressTimeout(), which is currently 500ms but may change (in 1.0 it was 1000ms but changed in a later release; maybe in the future it will be user-customizable).

The browser uses its own long press time because it has some more complicated interactions. I believe this should be 1000, though again it may change in the future. It is not adding the different timeouts together.

hackbod
Are you certain about this? My observation is 1650ms (1750ms to be certain with other process load) on the web browser. Can you site some lab notes or Android docs?
mobibob
.. also, looking at the source code, the LONG time does not start its time measurement until after short press is detected. That is why I believe it is cumulative along the state.I am not challenging your statement, just discussing to make certain that the answer is thorough and my question isn't misunderstood.
mobibob
Unfortunately (for me) this is the only correct answer to my question. But ... what I really wanted to learn was the time from the start of a press-hold until the browser pops-up a 'resolver' dialog. I am measuring 1.650 seconds so I want to find the missing 650ms. I am going to award the answer to hackbod and thank everyone else for their comments.
mobibob