If a user is running my app and decides to kill it via the task manager, are there any guarantees about how much code will be executed before the process dies?
I feel like it could stop running at any arbitrary line, however I guess I don't really know the answer to this.
An example use case is for stopping and restarting a background alarm. If I wanted to cancel an alarm, do some work, then reset the alarm, I feel like there is a chance that the app could stop running after the 'cancel alarm' step but before the 'reset alarm' step. This would leave me in a state that I don't want to be in because I always want my alarm to be set to go off in the future. (Keep in mind this is just an example, I'm not looking for workarounds to this specific case).
Is there anything I can do to ensure that code my java code runs as a 'transaction' similar to a db transaction so that it either all runs or none of it runs?