Long press on android

This is kind of a more general android question, but I thought it might still apply since this is for use with a jmonkey game.

This is kind of two questions, kind of related kind of not.

  1. In my game I want to use “long press” to perform certain actions. Is there any kind of built in api/official way to do this? or do i have to code my own using the raw input listener? I ask because if theres an “official” way to do it, id like to do it as to be compatible with any accessibility features on the device (or external input methods etc).

  2. in RawInputListener.onTouchEvent(evt) i see there is getPressure(), getScaleFactor(), and getScaleSpan(). What exactly are these values/ what are they measuring?

create a TouchListener. there is a method onTouch to implement.
To check for the long press just do

 if (event.getType() == TouchEvent.Type.LONGPRESSED) {
//do stuff

you should use this listener instead of the rawinputListener all those information are sent via the TouchEvent object


oh i never even realized there was a TouchListener, i thought AnalogListener and ActionListener were it. thanks.