0

Is there a way to know what time my device has been turned on?

Something like an adb command or something like that?

any idea?

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Antonio Prota
  • 13
  • 2
  • 4
  • Does anyone read questions before they mark duplicates anymore? How does adb have anything to do with starting a service when the device has turned on? They have nothing in common at all. – WalterM Jan 04 '16 at 11:41
  • @MarcinOrlowski, I agree with the previous commenter, I do not think this is a duplicate. Adb has nothing to do with starting a service at boot. This question is quite vague, yes, but not a duplicate. I think you should reopen. – Jonas Czech Jan 04 '16 at 11:56
  • I reopened the question yet for me it sill qualifies for closing as "unclear what you are asking". – Marcin Orlowski Jan 04 '16 at 13:09
  • You can use broadcast receiver for more detail you can use following link [stackoverflow.com/questions/7668836/how-to-start-a-service-when-the-android-device-is-turned-on](http://stackoverflow.com/questions/7668836/how-to-start-a-service-when-the-android-device-is-turned-on) – Akshay More Jan 04 '16 at 11:35

1 Answers1

0

If you want to know what at what time your device was turned on, you can go into Settings > About Phone > Status, and there you have an "Uptime" entry, which tells you how long the device has been on for. Subtract that from the current time, and you have the time the device was turned on.

You can also run the uptime command from adb or terminal, see this answer here.


If you want to do it in code, you can do something like:

System.currentTimeMillis() - SystemClock.elapsedRealtime();

Check this for more details: How to get Android system boot time

Community
  • 1
  • 1
Jonas Czech
  • 12,018
  • 6
  • 44
  • 65