Reputation: 3
I want to reset my activity, there are few functions and methods being performed in my class and i want that when i press the button everything resets and comes to a start just like at first how the activity gets started.
Upvotes: 0
Views: 101
Reputation: 5451
Try this :
Intent intent = getIntent();
overridePendingTransition(0, 0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
finish();
overridePendingTransition(0, 0);
startActivity(intent);
Upvotes: 0
Reputation: 551
Perhaps easier is this...
this.recreate();
there's some restriction about API less than 11 I think - you'd want to look that up if your app supports API less than 11.
Upvotes: 0
Reputation: 1127
Try this..
Intent intent = new Intent(this,yourActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Upvotes: 3
Reputation: 615
Easiest way:
Intent intent = getIntent();
finish();
startActivity(intent);
Upvotes: 0
Reputation: 7131
Try this:
Intent i = new Intent(YourActivity.this, YourActivity.class);
startActivity(i);
finish();
Upvotes: 1