I know how to track time when out of the current app. For instance I could start recording time the moment my app loads another app - then if the user comes back to my app in the onResume i can end the time and calculate duration.
The problem is if the user loads the other app from my app, then presses the home button and goes and uses other apps. I don't want to track that time. I only want to track the time used in a specific app. How do I do this?
The use case of this is that this app is an education app that tracks how much time you spend in certain education apps. If the student was to close the education app and play a game app instead, I would not want to count that as valid time.