0

I'm trying to create a monitor service which would know when apps start/resume/restart/pause/... and also when apps crashes.

I have tried to read logcat, but it seems that calls to [onCreate()/onStart()/onRestart()/...] are not logged into logcat.

Is there a way to catch all these method calls for all running apps ? Is there a way to know when an app crash ?

Note: The service don't need to be notified as soon as these events happens, few seconds/minutes after is also okay.

Michael Yaworski
  • 13,410
  • 19
  • 69
  • 97
anopse
  • 163
  • 1
  • 2
  • 9
  • you should be more clear of what's your main purpose. Is it crash tracking? Or jsut activity's lifecycle methods tracking? I'm going to add an answer for crash tracking now. but please update your answer. thanks – ersentekin Jan 02 '14 at 12:33
  • 1
    @ersentekin The main purpose is tracking all apps life's event, crashes are just another type of death event for my purpose. – anopse Jan 02 '14 at 14:34
  • 1
    This question has been asked, in various forms, numerous times. The answer is: No, it isn't possible to do this because there are no system events broadcast or logged for activity lifecycle changes. – David Wasser Jan 02 '14 at 14:42

2 Answers2

0

Refer to my code in this answer:

Android how to know an app has been started and range apps priority according the starting times

You can monitor it as follows:

If an app is in the foreground, that is if it is in start, then it will be the first item of the List taskInfo.

If it is paused, it will no longer be the first item in that list.

To check resume, see if it previously was not the first item, but , in the current iteration, it is the first item.

I am not too sure about the crash part, but maybe you can find a similar way from the above logic.

Community
  • 1
  • 1
SoulRayder
  • 5,072
  • 6
  • 47
  • 93
0

You can check out Crashlytics for crash tracking. You can see crashed lines in methods as well.

ersentekin
  • 654
  • 8
  • 20