I usually override onBackPressed()as follows:
@Override
public void onBackPressed() {
super.onBackPressed();
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(intent);
finish();
}
Only now I saw that when I press the "Back" button with this code , I see a white activity for 0.5 seconds during the transition.
Testing a bit I found that if I use this code, the problem will not be:
@Override
public void onBackPressed() {
Intent intent = new Intent(getApplicationContext(), HomeActivity.class);
startActivity(intent);
finish();
super.onBackPressed();
}
What is the difference between these two codes? If I use the second, is everything all right? Cause of a memory problem? thank
source
share