October 23, 2024
Chicago 12, Melborne City, USA
Android

How to implement real time app usage tracking for Android?


I’m trying to develop an Instagram usage management app for Android. After X minutes of usage, the user is redirected from Instagram to my app. My issue is accurately tracking Instagram usage in real time.

Since Android’s native UsageStats only updates upon app open and closure, it’s not helpful for my use case, as it’s likely the user would go over X minutes while still in Instagram.

I have tried to solve this by implementing a manual counter that triggers upon Instagram opening. However, it’s difficult to accurately track when Instagram is open, as the foreground event often reads as null even though Instagram is currently open. Having a "grace period" of not turning off Instagram tracking when it reads foreground null is not working, as sometimes the foreground reads null for quite awhile even though Instagram is open (for example, while watching a video and not touching the screen), so the tracking could be turned off too soon, and having too large a grace period to account for that would likely overcount after instagram exiting.

Are there any methods for accurately tracking app usage in real time?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video