How to Track App Usage in Android? How to detect when an activity is launched?

后端 未结 2 2035
忘掉有多难
忘掉有多难 2020-12-02 14:35

I need to track app usage in Android like how AppUsage does it (i.e. track number of app launches, and time spent using each). What I plan on doing is record the start time

2条回答
  •  北海茫月
    2020-12-02 15:27

    Basically, how do I detect when an activity is launched?

    You don't. There is nothing in the Android SDK for "the start time when an app is launched" nor "the end time when an app is paused or stopped".

    What the app you cite is probably doing is wasting a lot of CPU time, RAM, and battery life, polling ActivityManager continuously.

    Bear in mind that what you propose to track, if you plan on having anyone other than the user access it, borders on privacy violations of the type that got CarrierIQ in a fair amount of trouble.

提交回复
热议问题