0

I am new in android and trying to find solution to track android application termination events like

  1. when we remove application from application stack, application is closed but i could't find any method that track closing event

  2. when device got shutdown because of law battery application is closed but event could't be tracked

Krupesh Kotecha
  • 2,396
  • 3
  • 21
  • 40

1 Answers1

2

You can register a BroadcastReceiver in your application. Which will receive the SHUTDOWN Broadcast. You application will be notified when the phone is shutdown either due to battery low or the user shuts it down themselves. This is the broadcast you have to receive.

android.intent.action.ACTION_SHUTDOWN

There is no broadcast that notifies you about when the application is closed. You can however, get the list of currently running apps using the package manager. See this.

Community
  • 1
  • 1
Eric B.
  • 4,622
  • 2
  • 18
  • 33
  • i thing ACTION_SHUTDOWN will solve my issue. but what if application is closed from applcation stack? is there any solution? – Krupesh Kotecha Sep 25 '15 at 05:40
  • As i have mentioned in my answer, i think you can't. You can get the list of all the currently running apps. On second thoughts to know about if application is closed from application stack, you can override the onDestroy() method, of all your activities. So whenever you application is closed your onDestroy() will be called. – Eric B. Sep 25 '15 at 05:45