Question

Ok, so I've finally stumbled on the intersting point that finish() does not immediately terminate an activity but instead will continue the calling method to its end and then "finish".

Is there any other way to terminate/abort an activity? Ie, if X then abort(); just bails immediately at that point without executing anything else from the activity?

tia

Was it helpful?

Solution

If you want the calling method to exit immediately, just call return; after you call finish().

OTHER TIPS

There is not. The finish method is asynchronous, and it does a lot of things. After calling it, you will get, at some point the future, calls to onPause, (probably) onStop and (maybe) onDestroy if Android thinks it needs some memory.

As @joao points, let finish() be the last call in your routine and place a return after it, but do expect the calls to the onXXX methods.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top