如何跟踪应用程序使用Android中?如何检测当一个活动启动? [英] How to Track App Usage in Android? How to detect when an activity is launched?

查看:104
本文介绍了如何跟踪应用程序使用Android中?如何检测当一个活动启动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要跟踪应用程序的使用在Android中像AppUsage是怎么做的(应用程序启动的即轨道号,和每次使用花费)。我打算做的是记录的开始时间时,一个应用程序启动,然后得到当一个应用程序被暂停或停止的结束时间。在LogCat中,我能看到活动开始的日志。我已经看了可用的系统广播,我不知道是否有任何每当活动启动的广播。 。基本上,我怎么发现当一个活动启动?

编辑: 此外,机器人还具有内部可用的使用统计信息系统,该系统可以在零件程序中找到或当 *#*#4636#*#* 拨打(测试 - >使用统计)

解决方案
  

基本上,我怎么发现当一个活动启动?

您不知道。没有什么在Android SDK的,也不是结束时间时,一个应用程序被暂停或停止,当一个应用程序启动的开始时间。

什么你举很可能做的是浪费了大量的CPU时间,内存和电池寿命,轮询 ActivityManager 继续。

应用程序

记住,你提出来跟踪,对有任何人以外的其他用户访问它,如果你计划,边框上侵犯隐私,进行了CarrierIQ的麻烦相当数量的类型。

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 when an app is launched, and then get the end time when an app is paused or stopped. In LogCat, I'm able to see logs of Activity starting. I've looked at the available system broadcasts, I'm not sure if there is anything that broadcasts whenever an activity is started. . Basically, how do I detect when an activity is launched?

Edit: Moreover, Android also has a usage statistics system available internally which can be found in the Spare Parts app or when *#*#4636#*#* is dialed (Testing -> Usage statistics)

解决方案

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.

这篇关于如何跟踪应用程序使用Android中?如何检测当一个活动启动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆