启动一个应用程序的时间 [英] Launch Time of an app

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

问题描述

什么是启动一个应用程序,并计算出其发射时间在Android上最好的方式(如果它可以与一些code来完成,那么它的更好)

What is the best way to launch an app and calculate its launch time in android(if it can be done with some code,then its better)

推荐答案

嗯 - !首先,要多precise,我要指出的是,Android的启动活动,而不是应用程序

Hmm - first, to be more precise, I should point out that in Android you start activities, rather than applications!

所以,作为你的切入点,以您的应用程序是处理推出意图的活动,人们可以跨preT你的问题是如何衡量活动的启动时间。

So, as your entry point to your application is the Activity which handles the LAUNCH intent, one could interpret your question as "how to measure activity start up time".

对于这一点,我建议看看这里的活动周期:<一href="http://developer.android.com/intl/fr/reference/android/app/Activity.html#ActivityLifecycle">http://developer.android.com/intl/fr/reference/android/app/Activity.html#ActivityLifecycle.

For this, I suggest to look at an Activities lifecycle here: http://developer.android.com/intl/fr/reference/android/app/Activity.html#ActivityLifecycle.

看着漂亮的图形出现,你看到的启动时间基本上是花在的onCreate() ONSTART()的时间 onResume()

Looking at the nice graph there, you see that startup time is essentially the time that is spent in onCreate(), onStart() and onResume().

要衡量的是,我会建议使用 traceview 因为这样会真正展示你的一切,你花你的时间细节!开始跟踪使用 Debug.startMethodTracing(启动); 的onCreate的开始()和结束在跟踪结束 onResume() Debug.stopMethodTracing();

To measure that, I would suggest to use traceview as this will really show you in all its detail where you spent your time! Start tracing using Debug.startMethodTracing("startUp"); in the beginning of onCreate() and end tracing at the end of onResume() with Debug.stopMethodTracing();.

由于的onCreate()只调用一次每个实例,你甚至不必担心多次调用 onResume()的情况下,本次活动将投入到后台,你会调用stop方法两次,这是没有坏处!

Because onCreate() is only called once per instance, you don't even have to worry about multiple calls to onResume() in case this activity will be put to the background as you will call the stop method twice, which is no harm!

玩得开心! - 我喜欢traceview的可能性非常

Have fun - I like the possibilities of traceview very much!

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

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