tags:

views:

96

answers:

2

Hello, I need to generate/trigger a long key press event of a button in Android. Searched on net but not able to find any answers. Any solutions ??????/

Thanks in advance.

A: 

Can't you just start a TimerTask when you push the button, with 1 second delay, and just stop the timer if you release the button within that time?

Marcus Johansson
??????????/ not really understood.but do you want to say that invoke a down event of a button and then after a delay invoke it's up event.
viv
A: 

You can set Long key press on button like:

btnNext.setLongClickable(true);
btnNext.setOnLongClickListener(l)
Nishant Shah
Thanks for reply,I think, this will enable long click on button and set a listener for it.What i want is that for example key A(keydown event of a key) is pressed for some time.
viv
In your listener method before executing any code, put Thread.sleep(2000);It may help you.
Nishant Shah