I have problems to finish the activity before. I want to start another activity and finish the current activity. When I used finish
it didn't exit the current activity.
How can I exit the activity before?
Use finish like this: Intent i = new Intent(Main_Menu. this, NextActivity. class); finish(); //Kill the activity from which you will go to next activity startActivity(i);
In Activity [A], on button click, I am calling Activity [B] without finishing Activity [A]. Now in Activity [B], there are two buttons, New and Modify. When the user clicks on modify then pop an activity [A] from the stack with all the options ticked..
To allow other apps to start your activity in this way, you need to add an <intent-filter> element in your manifest file for the corresponding <activity> element.
You need to intent
your current context
to another activity first with startActivity
. After that you can finish
your current activity
from where you redirect.
Intent intent = new Intent(this, FirstActivity.class);// New activity intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); // Call once you redirect to another activity
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
- Clears the activity stack. If you don't want to clear the activity stack. PLease don't use that flag then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With