• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps How to get time of last system boot

horatio

Newbie
Hi All,

Does anyone know how to obtain the time of the last system boot? I need to determine where the system has been rebooted or powered off since the last time that my app was launched.

Thanks in advance,
Horatio.
 
You can use the SystemClock.elapsedRealtime() API to get the number of milliseconds since the phone was booted.

Thanks. I am already using that API. What I need to know is the time when the system itself was booted so that I can persist it and compare it to the last time that the system was booted and determine if the system was booted since my app was last launched.

Or to put it more generally, is it possible to determine by some other means whether the system was been rebooted between launches of an app.
 
Thanks. I am already using that API. What I need to know is the time when the system itself was booted so that I can persist it and compare it to the last time that the system was booted and determine if the system was booted since my app was last launched.

Or to put it more generally, is it possible to determine by some other means whether the system was been rebooted between launches of an app.

When your application starts up calculate last system boot time with the function you were given and compare when your application last was launched. This way you can find out whether application was booted before or after system boot. Then store the current time for the next time you boot up your application.
 
Back
Top Bottom