Sean
Sean

Reputation: 7045

I want to get the time of starting an application

The time is displayed in Logcat,
and I want to get it by codes because Logcat doesn't always display the time.
Any of the ways of solving it will be acceptable
Thanks and Regards,

Upvotes: 1

Views: 1611

Answers (2)

dstefanox
dstefanox

Reputation: 2222

Yon can try something like this:

  1. At the start of the code you want to measure, add

    int start = System.currentTimeMillis(); This gives you start point

  2. At the end of the code to measure, add

    int end = System.currentTimeMillis();

int duration = end - start; // That is duration you need.

Now you may append duration to file, post it to some service or do what ever you want to do with it...

Upvotes: 1

PearsonArtPhoto
PearsonArtPhoto

Reputation: 39748

You could just store the time when the application starts, using a Date() function. If it's the first line, then it'll get the start time, and you can print it out or whatever else you want, no problems.

Just a quick example of how you can use the date function. Log.d("Start_Time",new Date().toString())

Upvotes: 1

Related Questions