Use queryEvents method of UsageStatsManager class.
I've recently built an app for tracking daily app usage. Firstly, I tried using queryUsageStats but it didn't work properly. I thought it was supposed to return usage time from 12 am to current time when INTERVAL_DAILY is passed to it, but instead it was returning something else. Maybe there is a bug or there is something wrong on my side related to time zone or something.
Anyway, then I tried queryEvents and it worked fine.
Here's my implementation (See both the question and the accepted answer).