Skip to content

Tag: android

MVVM – get context in a Model class

I’m using MVVM to build my Android app and I need to connect the Model to a DB. Instead of Room I’m using the SQLiteOpenHelper and to make a connection to the DB I need the context. But since this is a non activity class I’m struggling to get it. My current solution looks as follows but I ke…

Android: get UsageStats per hour

I use UsageStats feature of Android, but the smallest interval is DAILY INTERVAL. How can I get UsageStats in an hourly interval? Answer All credit goes to this answer. I have learned from that one. How can we collect app usage data for customized time range (e.g. for per 1 hour)? We have to call queryEvents(…