I am working on a custom launcher where I am trying to override the Back button which is not working in the desired way.
The objective of this launcher is to launch a particular app (pre-defined) and load the list of installed Apps on back press. When this launcher is made to run it launches the desired App but loads the list of installed Apps on double back press. On single back press it either takes the user to a black screen or the previous screen (if any) and on another back press it loads a list of Apps. I have used keyCode
and onBackPressed()
.
The code is below.
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK)) {
Intent i = new Intent(this, AppListActivity.class);
startActivity(i);
this.finish();
return true;
}
return super.onKeyDown(keyCode, event);
}