I would like to know the time in which service get restarted by the android system. Is there any way that I can get this time?
Asked
Active
Viewed 151 times
1 Answers
-1
Viola.
public class MyService extends Service {
private long startTime;
public void onCreate() {
super.onCreate();
startTime = System.currentTimeInMillis();
}
}

chubbsondubs
- 37,646
- 24
- 106
- 138
-
This is the time when the service started. I want to know the time when the service got restarted by the system – Alex K May 29 '12 at 15:35
-
In order to be restarted you have to be shutdown. The second time the onCreate() method is called it will hold the restart time. So there is no difference between restart and start. Every time the service is started will be the restart. When the service is restarted it will be a new instance of your service so nothing persists between restarts. – chubbsondubs May 29 '12 at 16:35