I'm in the process of creating a set of home/back keys for when the statusbar in android is hidden. I've designed a button that simulates a home-key press as such
private void InjectKey(final int keyEventCode) {
new Thread(new Runnable() {
@Override
public void run() {
new Instrumentation().sendKeyDownUpSync(keyEventCode);
}
}).start();
}
which works just fine for home-key presses. However, when I try to apply the same solution to the back button, the app obviously just calls finish() on itself.
My question is this: How do I implement the backbutton so that it calls "back" on the latest app and on itself?
Thanks!