I need to generate/trigger a long key press event of a button in Android.
Any help regrading this?
From Android 2.0, Activity contains the method
public boolean onKeyLongPress(int keyCode, KeyEvent event)
For exemple, a long key press on the back button would be :
@Override
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK)
{
// do your stuff here
return true;
}
return super.onKeyLongPress(keyCode, event);
}
Take a look at this article.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With