1

I have a dumb question. Suppose an application is moved to the active state from the stopped state (this is related to having an app startup after BOOT_COMPLETED and moving the app out of the stopped state). But then the device is shutdown and there is a battery pull. When the device is restarted will the apps that were in the active state still be in that state? My guess is they will not but I want to confirm this (i.e. states are not saved).

Would the situation be any different if there were a battery pull without a shutdown - agreed, not a good situation.

The use case I am looking at is if a battery pull is required to move the system from a lockup condition - not specifically the Android device, but it may be on the same battery feed.

I looked through the ACTION_BATTERY... intents but did not get any insight with regards to this question. Thanks in advance.

JimCzek
  • 335
  • 1
  • 4
  • 17

2 Answers2

1

If you pulled the battery, you'll have to boot up the device fresh and all your Activity and Service lifecycles will behave accordingly.

Argyle
  • 3,324
  • 25
  • 44
1

The application state will never be saved upon a Restart. To persist data you will have to save them to either a database or somehow else.

Empty2k12
  • 475
  • 12
  • 34
  • Tnx. Looking further a lot of posts seem to use Restart and boot interchangeably. The original task was to start an app after booting is completed. There is a great deal of information about this and after Android 3.0 an app has to be moved from the stopped state before it can receive the BOOT_COMPLETED event. So it appears the only time this is possible is when the processor is rebooted without the device having been powered off since the app cannot revert to the stopped state. This would seem to limit this to situations where exceptions caused a reboot. Is this correct? – JimCzek Sep 23 '14 at 21:08
  • It turns out the information regarding whether or not an application is stopped resides in the file packages-stopped.xml. I found this while looking into the package manager. – JimCzek Sep 24 '14 at 19:28