So I have a button in activity 1 that when it is clicked, the apps goes to activity 2 using intent. So here in activity 2, I have programmed that when on back is pressed, return to activity 1. I have done the two following functions, but both of them apparently are doing exactly the same (They make the app to go back to activity 1 correctly), so I just want to know the difference between them:
//first function
@Override
public void onBackPressed() {
supportFinishAfterTransition();
}
//second function
@Override
public void onBackPressed() {
finish();
}
https://developer.android.com/reference/kotlin/androidx/fragment/app/FragmentActivity
States that
This is for Kotlin, but I really expect Java to behave in the same way.