I have tried to use the code below as described in other questions to Back button act like Home button, but it is not working:
@Override
public void onBackPressed() {
moveTaskToBack(true);
}
I don't have points to write a comment on others question, because of this I have opened this one.
1st issue: The HOME button is making the app quit. Only after the smartphone is reseted on the first time, the HOME button put the App in background (NOT quit)
2nd issue: I have tried to make the BACK button to act like HOME button with the code above, but the BACK button is only disabled.
. After the 1st SUCCESSFUL Login and Twitter Authentication, when the user clicks on the BACK button OR HOME button (Android buttons), the App has to stay in background (NOT quit).
What am I doing wrong?
Thanks
The App: http://play.google.com/store/apps/details?id=com.xranky
FIXED issue 2: with @zilk code below
FIXED issue 1: you have to insert the code below on the login/start screen
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
// Activity was brought to front and not created,
// Thus finishing this will get us to the last viewed activity
finish();
return;
}
// Regular activity creation code...
}
Source: How to return to the latest launched activity when re-launching application after pressing HOME?