0

How can I detect the start of my application from a completely terminated stated (as if the user went to Manage Applications and forced stopped the app)? I don't mean like a first-time start up when the user first installed the app nor do I mean just in an Activity by using onStart() or onCreate().

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Brian
  • 7,955
  • 16
  • 66
  • 107

2 Answers2

1

I'm not sure exactly what you're asking, but Application.onCreate() will be called when the application is starting, before any other application objects have been created. So you could use that to detect when an app is started from a non-running state.

Dheeraj Vepakomma
  • 26,870
  • 17
  • 81
  • 104
0

There's no way to detect when your app is "force stopped" from Android settings > apps page, or if the app is killed by another app. In both cases, the UNIX process is killed, and this severs the normal Android lifecycle.

Here's a post from dianne hackborn on the topic.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Jeffrey Blattman
  • 22,176
  • 9
  • 79
  • 134
  • I'm not asking to detect when the app is forced stopped, I want to detect when the app is started from a forced stop. – Brian Mar 27 '12 at 03:21
  • @Brian How do you expect to detect if your app is started from a force stop if you cannot detect if your app is force stopped in the first place! (this seems to be what Blattman has pointed out) – IamAlexAlright Mar 27 '12 at 03:36
  • I apologize that my wording isn't very accurate but I simply wanted to see if there was a broadcast or something I could use to detect when an app is started from a non-running state (I used forced stop as an example). I can completely understand why an app wouldn't be able to detect a force stop, but that's not what I'm looking for. Anyway, if this isn't possible, that's alright. – Brian Mar 27 '12 at 04:52