0

Is there library in Android that can provide me the total spend time of a user in my application without using my own time count?

I believe that Android OS is counting all application use time the same way as they count battery use ,network, etc.. If my assumptions are right, What I need is this system count for my application use time.

2 Answers2

0

You can use Fabric (https://fabric.io/) there's some a lot useful tools that you can use, it also can track Daily Active User, Crash Reporting, etc.

They also provide us easy integration step, just take few minutes to integrate our system with Fabric.

AFin
  • 61
  • 2
-1

The general approach to this is to:

  1. Get the time at the start of your benchmark, say at the start of main().
  2. Run your code.
  3. Get the time at the end of your benchmark, say at the end of main().
  4. Subtract the start time from the end time and convert into appropriate units.

A simpler way is this.

long startTime = System.nanoTime();
.....your program....
long endTime   = System.nanoTime();
long totalTime = endTime - startTime;
System.out.println(totalTime);
Tushar Narang
  • 1,997
  • 3
  • 21
  • 49