0

I want to make an app that when it is running and for some reason the device goes off, when the user boots the device again the app will continue running, not necessarily from the point where it stopped.

dothedos
  • 169
  • 5
  • 20
  • does this help? http://stackoverflow.com/q/1056570/932051 – abhinav Dec 20 '11 at 08:41
  • Yeah, i have already seen that,but i do not want to start on boot everytime. Only if it is running and the battery goes off. On that boot only. – dothedos Dec 20 '11 at 08:45

1 Answers1

1

now that you know how to start your your app right after the device boot, why not set a boolean variable to record how the app exits,normally or being disturbed by power off? and commit thfor value of the variable into a sharedpreference, so when the device reboots,you can decide to :start your app or not.

Huang
  • 4,812
  • 3
  • 21
  • 20
  • And how exactly i record that? I use a receiver to catch the intent on how the battery changed(battery_health_dead)? – dothedos Dec 20 '11 at 10:02
  • sorry,I typed on my phone. I will reply you when I get back home. – Huang Dec 20 '11 at 10:10
  • what is your purpose and process exactly? you just mentioned you had another receiver,but I don't see the connection between it and your receiver. – Huang Dec 20 '11 at 11:35
  • I just want to know when my app is killed by the death of the battery and if that is happened, the app will start again on boot – dothedos Dec 20 '11 at 11:42
  • when the app is killed ,the onPause() method will be called, inside it,you can query the battery level. if it is too slow,you can commit a value into the SharedPreference file.Every time when the phone boots up,check that value to see if your app exits because of low battery. This is my idea to solve it. – Huang Dec 20 '11 at 12:00