Monthly Archives: January 2014

[Android] Mimic press event of Back button

Must dispatch both ACTION_DOWN and ACTION_UPDATE KeyEvent

// trigger button back programmatically 

this.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK));

this.dispatchKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK));

Advertisements