Reputation: 2956
I have an app for sending sms. It consists of several "cascading" activities - one for writing text, next for choosing number and next for confirming before sending. After sending the message I want that all activities get closed. How can i do this?
Upvotes: 0
Views: 167
Reputation: 64700
If you start all the Activities with startActivityForResult
you can chain the finish
calls in onActivityResult
: basically make the final Activity call finish
after setting a specific result code, and each earlier activity checks for that result code and if its there does the same thing. They'll all close up cleanly and you should be all set.
Upvotes: 0
Reputation: 1006674
You will find no well-written Android apps that have this behavior.
After sending the message, you are welcome to send them back to your main activity using Intent.FLAG_ACTIVITY_CLEAR_TOP
, which will remove all intervening activities between the current one and the main activity, using something like:
Intent intent = new Intent(this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
Upvotes: 2