I have one activity A and when I click on one button from activity A and come to an another activity B and when I click on back arrow from activity B to go back to A, its comes to the same activity B, so I need to click the back arrow again to go back and when I click on second time, it works.
I have used below approach.
@Override
public void onBackPressed() {
super.onBackPressed();
}
I have also used onKeyDown() approach. But it does not work, its comes to the same activity B, so I need to click the back arrow again to go back to previous activity.
Is there any way to prevent this from happening?
You need to define the parent Activity of your Activity in your Manifest and get lost of the onBackPressed method:
That is how it is done.