Android在其他设备上测试我的应用时,只有一些似乎拿起我的drawables

时间:2014-07-24 03:48:00

标签: android bitmap

我试图在所有密度上使用简单的动画测试我的应用程序,但是在模拟器上测试高密度和低密度手机时(Nexus One 4.2.2用于hdpi,WQVGA 4.2.2用于ldpi)我的位图没有被绘制出来。我加倍检查我为所有文件夹命名的位图是相同的,并且适当地缩放它们并且似乎没有任何帮助。如果有帮助,我会使用此示例单独调整大小。

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
switch(metrics.densityDpi){
 case DisplayMetrics.DENSITY_LOW:
            break;
 case DisplayMetrics.DENSITY_MEDIUM:
             break;
 case DisplayMetrics.DENSITY_HIGH:
             break;
}

这是我的logcat:

07-24 03:32:53.424: E/Trace(822): error opening trace file: No such file or directory     (2)
07-24 03:32:54.514: D/dalvikvm(822): GC_CONCURRENT freed 33K, 6% free 2774K/2932K,     paused 18ms+17ms, total 132ms
07-24 03:32:54.574: D/dalvikvm(822): GC_FOR_ALLOC freed 6K, 6% free 2845K/2996K, paused    27ms, total 28ms
07-24 03:32:54.584: I/dalvikvm-heap(822): Grow heap (frag case) to 3.500MB for 635812-byte allocation
07-24 03:32:54.636: D/dalvikvm(822): GC_FOR_ALLOC freed <1K, 5% free 3466K/3620K, paused 48ms, total 48ms
07-24 03:32:54.684: D/dalvikvm(822): GC_CONCURRENT freed 1K, 5% free 3470K/3620K, paused 18ms+5ms, total 48ms
07-24 03:32:54.684: D/dalvikvm(822): WAIT_FOR_CONCURRENT_GC blocked 19ms
07-24 03:32:54.694: I/dalvikvm-heap(822): Grow heap (frag case) to 4.968MB for 1536016-byte allocation
07-24 03:32:54.744: D/dalvikvm(822): GC_FOR_ALLOC freed <1K, 4% free 4970K/5124K, paused 43ms, total 44ms
07-24 03:32:55.405: I/Choreographer(822): Skipped 43 frames!  The application may be doing too much work on its main thread.
07-24 03:32:55.424: D/gralloc_goldfish(822): Emulator without GPU emulation detected.
07-24 03:32:55.815: I/Choreographer(822): Skipped 64 frames!  The application may be doing too much work on its main thread.

1 个答案:

答案 0 :(得分:0)

您遇到的错误是因为您在主线程上做了太多工作。使用ASYNC TASKS来实现这个目的,在那里做所有后台工作然后onPostExecute显示结果。其次,如果位图或可绘制的大小太大,它将无法正确呈现而不显示导致有时OutofMemory异常和其他。目前我在你的日志文件中看到的是你在UIThread上做了太多工作,这不是一个好的练习并阻止应用程序操作导致ANR,即应用程序没有响应。