Reputation:
Is there any way to save what time the Android device shut down. If for example the phone battery dies, can i save the time the phone shuts off. Then call this time at a later stage, when the phone is back on.
Upvotes: 0
Views: 193
Reputation: 7703
You can use the ACTION_SHUTDOWN
broadcast receiver. In the ACTION_SHUTDOWN
broadcast receiver you can save the current time to your SharedPreferences
. For example using System.currentTimeMillis();
and retrieve it back later.
https://developer.android.com/reference/android/content/Intent.html#ACTION_SHUTDOWN
Upvotes: 4