`
- 浏览:
1647205 次
-
如何统计Activity启动所用的时间?<wbr style="line-height:25px"><div style="line-height:25px">可以通过分析Log得到(这个就是DDMS的那个Log)。</div>
<div style="line-height:25px">当我们点击触摸时会了类似以下的Log<span style="line-height:25px"><span style="color:#993300; line-height:25px">A</span></span>:</div>
<div style="line-height:25px">
<div style="line-height:25px">
<div style="line-height:22px">
<span style="color:#0000ff; line-height:22px">03-06 03:36:47.865: VERBOSE/InputDevice(2486): ID[0]=0(0)</span><span style="color:#ff9900; line-height:22px">Dn</span><span style="color:#0000ff; line-height:22px">(0=>1)</span>
</div>
<div style="line-height:22px"><span style="color:#3366ff; line-height:25px">03-06 03:36:47.865: INFO/PowerManagerService(2486): Ulight 3->7|0</span></div>
<div style="line-height:22px"><span style="color:#3366ff; line-height:25px">03-06 03:36:47.933: INFO/(2486): PRODUCT_SHIP = false</span></div>
<div style="line-height:22px">
<span style="color:#0000ff; line-height:22px">03-06 03:36:47.933: VERBOSE/InputDevice(2486): ID[0]=0(0)</span><span style="color:#ff9900; line-height:22px">Up</span><span style="color:#0000ff; line-height:22px">(1=>0)</span>
</div>
</div>
</div>
<div style="line-height:25px">当系统收到一个启动Activity的Intent时会有类似以下的Log<span style="color:#993300; line-height:25px">B</span>:</div>
<div style="line-height:25px">
<span style="color:#3366ff; line-height:25px">03-06 03:36:47.954:</span><span style="color:#0000ff; line-height:25px">INFO/ActivityManager(2486): Starting activity</span><span style="color:#3366ff; line-height:25px">: Intent {
act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.teleca/.ContextMenuActivity }</span>
</div>
<div style="line-height:25px">当系统完成Activity进程启动时会有类似以下的Log<span style="line-height:22px">C</span>:</div>
<div style="line-height:25px">
<span style="color:#3366ff; line-height:25px">03-06 03:36:48.068:</span><span style="color:#0000ff; line-height:25px">INFO/ActivityManager(2486): Start proc</span><span style="color:#3366ff; line-height:25px">com.teleca for activity
com.teleca/.ContextMenuActivity: pid=2933 uid=10089 gids={}</span>
</div>
<div style="line-height:25px">当系统完成显示一个Activity时会有类似以下的Log<span style="line-height:25px">D</span>:</div>
<div style="line-height:25px">
<span style="color:#3366ff; line-height:25px">03-06 03:36:48.302:</span><span style="color:#0000ff; line-height:25px">INFO/ActivityManager(2486): Displayed activity com.teleca/.ContextMenuActivity: 240 ms (total 41289 ms)</span>
</div>
<div style="line-height:25px">那么启动Activity所用的<span style="color:#000080; line-height:25px">所有时间</span>=<span style="color:#000080; line-height:25px">LogD</span><span style="line-height:22px">那刻</span><span style="line-height:22px">时间</span><span style="color:#ff9900; line-height:25px"><span style="line-height:25px">减去</span></span><span style="color:#000080; line-height:25px">Log</span><span style="line-height:22px"><span style="color:#000080; line-height:25px">A</span><span style="line-height:25px"></span></span><span style="line-height:22px">那刻</span><span style="line-height:22px">时间。</span>
</div>
<div style="line-height:25px">
<span style="line-height:22px">即:</span><span style="line-height:25px">03:36:48.302</span><span style="color:#0000ff; line-height:25px">减去</span><span style="line-height:25px"></span><span style="line-height:22px">03:36:47.933,简化即为:</span><span style="line-height:25px"><span style="line-height:22px"><span style="line-height:22px">48.302</span></span></span><span style="color:#ff6600; line-height:25px">减去</span><span style="line-height:22px">47.933=<span style="color:#339966; line-height:25px">369ms</span><span style="line-height:25px">.</span></span>
</div>
<div style="line-height:25px">注1:<span style="color:#000080; line-height:25px">从</span><span style="color:#339966; line-height:25px">Log<span style="line-height:22px">A</span></span><span style="line-height:22px; color:rgb(0,0,128)">到</span><span style="color:#008000; line-height:25px">Log<span style="line-height:22px">B</span></span><span style="line-height:22px; color:rgb(0,0,128)">为系统所用时间。:</span>
</div>
<div style="line-height:25px">
<span style="line-height:22px">注2:</span><span style="line-height:22px"><span style="color:#000080; line-height:25px">从</span><span style="color:#99cc00; line-height:25px">Log<span style="line-height:22px">B</span></span><span style="line-height:22px; color:rgb(0,0,128)">到</span><span style="color:#808000; line-height:25px">Log</span><span style="color:#808000; line-height:25px">D</span><span style="color:#0000ff; line-height:25px">主要</span><span style="color:#000080; line-height:25px">是</span></span><span style="line-height:22px"><span style="color:#993300; line-height:25px">activity</span></span><span style="line-height:22px; color:rgb(0,0,128)">本身创建所用的时间(on
create(),onresume(),onDraw()等)</span><span style="color:#000080; line-height:25px">。</span><span style="line-height:22px"><span style="line-height:25px; color:rgb(0,0,128)">48.302</span><span style="color:#ff6600; line-height:25px">减去</span></span><span style="line-height:22px"><span style="color:#000080; line-height:25px">47.954=</span><span style="line-height:22px"><span style="color:#339966; line-height:25px">348ms</span><strong>.</strong></span><span style="line-height:22px; color:rgb(0,0,128)">有时也包括了</span></span><span style="line-height:22px; color:rgb(0,0,128)"><span style="line-height:22px">系统为</span></span><span style="color:#000080; line-height:25px">创建</span><span style="line-height:22px"><span style="color:#993300; line-height:25px">activity</span><span style="color:#000080; line-height:25px">所在应用程序(APK)</span></span><span style="line-height:22px; color:rgb(0,0,128)">进程所用的时间</span><span style="line-height:25px; color:rgb(0,0,128)">。</span>
</div>
<div style="line-height:25px">注3:<span style="color:#339966; line-height:25px">Log D</span><span style="line-height:22px"></span><span style="line-height:22px">的</span><span style="line-height:22px">“</span>240 ms<span style="line-height:22px">”</span><span style="line-height:22px">和</span><span style="line-height:22px">“</span>(total
41289 ms)<span style="line-height:22px">”</span><span style="line-height:22px">的意义还不清楚。只是”240ms“和</span><span style="color:#99cc00; line-height:25px">Log C</span><span style="line-height:22px">到</span><span style="color:#808000; line-height:25px">Log D</span>的时间很接近<span style="line-height:25px">。</span>
</div>
<div style="line-height:25px"><span style="line-height:25px">附件1:</span></div>
<div style="line-height:25px">一个启动<span style="line-height:22px">activity的Log:</span>
</div>
<div style="line-height:25px">
<div style="line-height:25px">
<div style="line-height:25px"><span style="color:#0000FF; line-height:25px">03-06 03:36:47.865: VERBOSE/InputDevice(2486): ID[0]=0(0) Dn(0=>1)</span></div>
<div style="line-height:25px">03-06 03:36:47.865: INFO/PowerManagerService(2486): Ulight 3->7|0</div>
<div style="line-height:25px">03-06 03:36:47.933: INFO/(2486): PRODUCT_SHIP = false</div>
<div style="line-height:25px"><span style="color:#0000FF; line-height:25px">03-06 03:36:47.933: VERBOSE/InputDevice(2486): ID[0]=0(0) Up(1=>0)</span></div>
<div style="line-height:25px">03-06 03:36:47.935: VERBOSE/WindowManager(2486): Dsptch 1 x82.0 y592.0 > Window{485bd6c0 com.sec.android.app.twlauncher/com.sec.android.app.twlauncher.Launcher paused=false}</div>
<div style="line-height:25px"><span style="color:#0000FF; line-height:25px">03-06 03:36:47.954: INFO/ActivityManager(2486): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.teleca/.ContextMenuActivity
}</span></div>
<div style="line-height:25px">03-06 03:36:48.029: INFO/Launcher(2570): onPause()</div>
<div style="line-height:25px">03-06 03:36:48.044: DEBUG/AudioHardwareALSA(2377): ALSA OPEN mode 0,device 2</div>
<div style="line-height:25px">03-06 03:36:48.044: INFO/AudioHardwareALSA(2377): Try to open ALSA PLAYBACK device AndroidPlayback_Speaker_normal</div>
<div style="line-height:25px">03-06 03:36:48.048: WARN/Launcher(2570): WallpaperManager setVisibility visible true</div>
<div style="line-height:25px"><span style="color:#0000FF; line-height:25px">03-06 03:36:48.068: INFO/ActivityManager(2486): Start proc com.teleca for activity com.teleca/.ContextMenuActivity: pid=2933 uid=10089 gids={}</span></div>
<div style="line-height:25px">03-06 03:36:48.099: INFO/AudioHardwareALSA(2377): Initialized ALSA PLAYBACK device AndroidPlayback_Speaker_normal</div>
<div style="line-height:25px">03-06 03:36:48.099: DEBUG/AudioHardwareALSA(2377): Set PLAYBACK PCM format to S16_LE (Signed 16 bit Little Endian)</div>
<div style="line-height:25px">03-06 03:36:48.099: DEBUG/AudioHardwareALSA(2377): Using 2 channels for PLAYBACK.</div>
<div style="line-height:25px">03-06 03:36:48.099: DEBUG/AudioHardwareALSA(2377): Set PLAYBACK sample rate to 44100 HZ</div>
<div style="line-height:25px">03-06 03:36:48.099: DEBUG/AudioHardwareALSA(2377): Buffer size: 2048</div>
<div style="line-height:25px">03-06 03:36:48.099: DEBUG/AudioHardwareALSA(2377): Latency: 46439</div>
<div style="line-height:25px">03-06 03:36:48.134: INFO/WindowManager(2486): Setting rotation to 1, animFlags=1</div>
<div style="line-height:25px">03-06 03:36:48.154: INFO/ActivityManager(2486): Config changed: { scale=1.0 imsi=0/0 loc=en_CA touch=3 keys=1/1/2 nav=1/1 orien=2 layout=34 uiMode=17 seq=3 FlipFont=0}</div>
<div style="line-height:25px">03-06 03:36:48.189: INFO/Launcher(2570): onWindowFocusChanged(false)</div>
<div style="line-height:25px"><span style="color:#0000FF; line-height:25px">03-06 03:36:48.302: INFO/ActivityManager(2486): Displayed activity com.teleca/.ContextMenuActivity: 240 ms (total 41289 ms)</span></div>
<div><span style="color:#0000FF; line-height:25px"><br></span></div>
</div>
</div>
</wbr>
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
从application启动activity
042集-跨进程启动Activity和设置Activity多个入口!
使用appWidget启动一个Activity
LauncherActivity 开发启动Activity的界面Demo
简单的去理解 启动activity的方式 主要是介绍了 startActivityForResult 这个API
android开机启动Activity/Service/App的三合一demo,本人写了一个小小demo,把如果开机自启动Activity、Service、APP写了下,欢迎下载。
显示Intent和隐式Intent启动Activity的示例
Android 内部 启动Activity 时序图,了解activity在系统的启动流程对Android开发的同事很有帮助
NULL 博文链接:https://410063005.iteye.com/blog/1941314
Activity启动模式设置: <activity android:name=".MainActivity"android:launchMode="standard" /> Activity的四种启动模式: 1.standard 模式启动模式,每次激活Activity时都会创建Activity,并放入任务栈中。 ...
Activity和Service是应用程序的核心组件,程序框架层提供了一套完整的机制来协助应用程序启动Activity和Service
demo 博文链接:https://null-point.iteye.com/blog/2194997
Intent启动Activity样例
主要为大家详细介绍了Android利用Intent启动和关闭Activity的相关操作,感兴趣的小伙伴们可以参考一下
standard是最常见的activity启动方式,也是默认的启动的方式。当启动一个activity的时候他将进入返回栈的栈顶。系统不会管栈内是否有相同的activity,方式像后入先出。 singleTop方式是在活动启动的时候,系统先...
2、启动activity-显示启动和隐式启动: 3、隐式启动自己的activity 4、获取隐启动传递过来的data数据 5、显示启动传递数据 6、禁用掉横竖屏切换 7、开启activity获取返回值-startActivityForResult:
activity的启动方式,支持一下,谢谢
点击通知启动多个Activity.从启动Activity 返回不会退出app,而是返回到App 的MainActivity 或者其他Activity
安卓开发实现开机启动跳转到指定activity
完全免费,整了一天时间,才弄出来,可以直接运行,欢迎下载