Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

Where can I get the information about when and what time my Android phone is being shut down and also being start up. (shut down / start up - meaning that someone press the Power button to cause it to shut down / start up OR a program that cause it to start it or shut it.)

Information should look something similar like the following:

=========================================================
| Date          |  Time       |  Operation |   By       |
=========================================================
| 12 Dec 2012   |  11:59 PM   | Shutdown   |   User     |
| 13 Dec 2012   |  10:00 AM   | Startup    |   User     |
| 13 Dec 2012   |  10:59 AM   | Shutdown   |   Program  |
| 13 Dec 2012   |  02:16 PM   | Startup    |   User     |
=========================================================

If the shut down or start up is caused by a Program, it would be better to display the program name that cause it to shutdown.

Prefer method that does not require rooting and for Android version below 4.

share|improve this question
    
Just to be sure, are you asking about the phone completely shutting down and starting up (ie a reboot)? Or do you rather mean the screen turning off and turning back on (ie sleep mode)? –  Stephen Schrauger Dec 14 '12 at 14:34
    
Also, without root, any non-system app should be unable to shutdown the phone. So the only time a phone would shut down or reboot is if the user specifically said so (excluding hardware events like a battery dying). –  Stephen Schrauger Dec 14 '12 at 14:37
    
You say. I saw phones suddenly rebooting on a system crash (something messed up in the Dalvik Cache probably). So that was surely not a user-initiated shutdown :) –  Izzy Dec 14 '12 at 14:47

1 Answer 1

My standard recommendation again here: Tasker, the most complete automation solution available for Android. Tasker can react on different events and perform tasks when they occur. So you could setup two profiles:

  • Profile "Startup":
    • Condition: Device Boot (this is boot_completed))
    • Task: Write File (with your information specified in the parameters)
  • Profile "Shutdown":
    • Condition: Device Shutdown
    • Task: Write File (with your information specified in the parameters)

For the text you can use Variables like e.g. %DATE. Only difficulty will be to determine whether the shutdown was caused by the user or a program -- no easy recipe here, especially not for un-rooted devices. This information might be extracted from the system logs somehow; but starting with JellyBean, this would require root permissions.

share|improve this answer
    
Was wondering on the following if there are any free Apps with just this function only. (I like your recommendation but Tasker have too many useful functions that I felt I am being overwhelmed). At least I know that I should not upgrade to JellyBean cause it seems that JellyBean need the user to root the phone in order to get basic features. (Was wondering why not the JellyBean phone is rooted in the first place, would not it be much better?) –  Jack Dec 14 '12 at 7:52
    
Sure, every 2nd answer I give mentions Tasker :) It's what I use as it's most flexible. There are many free similar apps, but I cannot tell you whether/which supports this. As for root: ALL phones should come rooted if you ask me -- like all *nix come with root and Windows with handles (oh, oops... the other Windows with "Administrator")... –  Izzy Dec 14 '12 at 9:20
    
I tried Tasker but found could not get the variable which shows the shutdown or startup is caused by the user or a program. I also could not find something like SHUTDOWN_BY that can tell me which program / user caused shutdown. Any ways to find this information? –  Jack Dec 17 '12 at 3:15
    
That would be a bit more tricky: you probably will have to parse the system logs for that. There is no Tasker Variable telling you what caused the shutdown. If your device is rooted, the commands dmesg and logcat might prove useful -- but I've got no complete recipe ready. –  Izzy Dec 17 '12 at 6:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.