I have activity a and b, when I in activity b and preesed on the back key I back from activity b to activity a, How do I make that when I back to activty a, activty a will be restart?
Asked
Active
Viewed 29 times
-2
-
why do you want to restart your activity A? – Sarthak Mittal Nov 22 '14 at 17:49
-
You realize that if you do that you will end up creating a loop, right? – An SO User Nov 22 '14 at 17:51
1 Answers
0
When your are launching activity B you should call finish() on activity A
Intent intent=new Intent(this.,B.class)
startActivity(intent);
finish():
**override onBackPressed method of the Activity b **
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
super.onBackPressed();
Intent intent=new Intent(this,A.class);
startActivity(intent);
finish();
}

Arun Salaria
- 984
- 6
- 20