如何知道多少长时间的应用程序在Android的运行? [英] How to know for how much long the application is running in android?

查看:118
本文介绍了如何知道多少长时间的应用程序在Android的运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做Android的应用程序需要知道多长时间运行该应用程序。难道有谁知道如何获取这些信息?。有没有什么办法,其中Android提供有关运行的应用程序的信息,从他们有多少时间运行??

I am doing an application in android which requires to know for how long the application is running. Do anyone know how to retrieve such information??. Is there any way where android provides the information about the running applications ,from how much time they are running??

推荐答案

我不知道这将处理任何方法,但你可以简单地实现它自己。刚刚捕获当前时间(秒),并在的onPause()方法做同样的。然后,只需减去第一次保存的时间值,最后保存的价值,你应该知道的应用程序有多少秒运行。

I'm not aware of any method which would handle that but you can simply implement it yourself. Just capture the current time in seconds and in the onPause() method do the same. Then just subtract the first saved time value and the last saved value and you should know for how many seconds the application was running.

有可能是另一种更优雅的解决方案,我不知道寿。

There might be another more elegant solution I don't know of tho.

这篇关于如何知道多少长时间的应用程序在Android的运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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