获取Android应用程序启动时间处于非活动类 [英] Get Android App Start Time in a non-activity class

查看:195
本文介绍了获取Android应用程序启动时间处于非活动类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要获取Android应用程序的启动日期时间。做最简单的方法是要注意在活动课的OnCreate当前时间,但我的问题是,我创造了一些实用功能的机器人库。我想了解最终用户的应用程序的启动日期时间(即使用库)库本身。我不想绑定的应用程序开发人员记下在onCreate方法的开始时间,并传递到库的方法。

I want to get the start datetime of the android application. The simplest way to do is to note the current time in the onCreate of activity class, but my issue is that I am creating an android library with some utility functions. I want to find out the start datetime of end user application (that is using the library) within the library itself. I don't want to bound the app developer to note down the start time in the onCreate method and pass to the library method.

考虑到这种情况下,有没有办法做到这一点?

Considering this scenario, is there any way to do this?

推荐答案

getElapsedCpuTime()在android.os.Process应该给你你想要什么:

getElapsedCpuTime() in android.os.Process should give you what you want:

http://developer.android.com/reference/android/os/Process.html#getElapsedCpuTime()

这是应该由默认返回经过的CPU时间调用进程的静态方法。

It's a static method that should by default return the elapsed cpu time for the calling process.

这篇关于获取Android应用程序启动时间处于非活动类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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