views:

42

answers:

1

I have a pretty standard iPhone app that creates a series of around 7 unique Activities initialised by Intents.

However if the app crashes on the 7th Activity, the app restarts on the users phone around the 5th activity. The problem then is the info gathered from activities 1-4 is null, meaning the app is useless and the only way to get the app working again is to either continually press back or else kill the process.

Why does this behaviour occur, and is there a way to force the app to start back at the first activity when it crashes.

A: 

Your app is restarting in the activity that was beyond the crashed activity on the activity stack. You can finish all activities that are beyond your current one through calling

this.finish();

after starting the next activity.

The problem is that the user now can not press the back button to change data that was inserted in the steps before because those activities are gone.

You may have a general problem with data persistence over pause and resume cycles. Try to call your emulator or phone while you are in one of the deeper activities and then return to the app through long pressing the home button. You may see that the data from previous activities is now also empty. Play around with this behaviour and have a look at the application life cycle documents.

This may be a way to check if data is available and if not close the activity or go back to the start activity.

Janusz