0

I want to know how much time i spent in my application (facebook , messenger ... ) in android studio

I've seen this post How to Get the Time spent on an application in Android Programmatically

But i have an empty list from usageStatsManager.queryUsageStats

Any other valuable source or an idea how to correct the issue that i am facing.

Yagami Light
  • 1,756
  • 4
  • 19
  • 39
  • Hi Yagami Light, [this answer](https://stackoverflow.com/questions/59113756/android-get-usagestats-per-hour/59362638#59362638) can help you. – Md. Sabbir Ahmed Mar 28 '21 at 09:08

1 Answers1

0

The docs require PACKAGE_USAGE_STATS, which sounds like a system level permission.

Protection level: signature|privileged|development|appop|retailDemo

A convenience method that queries for all stats in the given range (using the best interval for that range), merges the resulting data, and keys it by package name. See queryUsageStats(int, long, long).

The caller must have Manifest.permission.PACKAGE_USAGE_STATS

Ilya Gazman
  • 31,250
  • 24
  • 137
  • 216