5

我有一个 android 应用程序,在单击它的图标后需要 >=5 秒才能显示出来。

单击该图标后,我会在状态栏中看到带有应用程序名称的黑屏。5 秒以上后,主屏幕出现。

我在 SO 上引用了这篇文章,我从堆栈跟踪中得到了以下结果

16:13:14.915: I/ActivityManager(59): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=packageName/.SelectType }
16:13:14.954: I/SurfaceFlinger(59): 
16:13:14.954: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->mIdentity=176, LayerName= Starting packageName
16:13:14.954: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->clientIndex=2, surfaceHandle->mToken=0x2
16:13:16.026: D/AnrParser(184): Waiting kernel log . . .
16:13:16.614: D/dalvikvm(6890): GC_FOR_MALLOC freed 12274 objects / 785016 bytes in 135ms
16:13:17.784: D/dalvikvm(133): GC_EXTERNAL_ALLOC freed 415 objects / 21624 bytes in 1285ms
16:13:17.914: D/dalvikvm(6890): GC_FOR_MALLOC freed 5762 objects / 339024 bytes in 90ms
16:13:18.174: D/AnrParser(184): Waiting kernel log . . .
16:13:18.344: E/keystore(6966): chdir: /data/misc/keystore: Permission denied
16:13:19.693: D/dalvikvm(6890): GC_FOR_MALLOC freed 5994 objects / 372624 bytes in 93ms
16:13:20.173: D/AnrParser(184): Waiting kernel log . . .
16:13:22.173: D/AnrParser(184): Waiting kernel log . . .
16:13:22.743: I/SurfaceFlinger(59): 
16:13:22.743: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->mIdentity=177, LayerName= packageName/packageName.SelectType
16:13:22.743: I/SurfaceFlinger(59): SurfaceFlinger::createSurface() : layer->clientIndex=0, surfaceHandle->mToken=0x0
16:13:22.983: D/dalvikvm(6890): GC_FOR_MALLOC freed 21467 objects / 1097728 bytes in 119ms
16:13:23.403: E/keystore(6973): chdir: /data/misc/keystore: Permission denied
16:13:24.173: D/AnrParser(184): Waiting kernel log . . .
16:13:24.923: W/ActivityManager(59): Launch timeout has expired, giving up wake lock!
16:13:25.264: W/ActivityManager(59): Activity idle timeout for HistoryRecord{47f56388 packageName/.SelectType}
16:13:25.403: I/ActivityManager(59): Displayed activity packageName/.SelectType: 10206 ms (total 10206 ms)

正如您在上面的日志中看到的,第一条语句是16:13:14.915: I/ActivityManager(59): Starting activity,最后一条语句是16:13:25.403: I/ActivityManager(59): Displayed activity

所以有一个大约的差距。10 到 11 秒。

任何帮助表示赞赏。

4

1 回答 1

2

您可能在活动的 onCreate() 或 onResume() 上执行了一些繁重的操作……尝试调试它以查看您是否直接在这些方法中执行数据库或 I/O 操作。您还可以激活StrictMode以更好地了解导致应用程序变慢的原因。

于 2013-03-19T11:07:04.117 回答