我創建了一個只包含ImageView的應用程序。使用高分辨率的圖像會導致BITMAP錯誤?
此外,根據應用程序的要求,我不得不使用高品質的圖像與1024 * 780分辨率到200 * 250分辨率的圖像。所有圖像總計有近45個圖像!!!。
高端(堆存儲器> = 32)的設備,我發現它運行平穩,來到低端(堆存儲器< 32)裝置&也MICROMAX A 65,我收到的一些崩潰報告&我嘗試了一個16mb的堆內存模擬器。
點擊圖像後它顯示:
06-29 05:16:28.572: W/dalvikvm(846): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
06-29 05:16:28.665: E/AndroidRuntime(846): FATAL EXCEPTION: main
06-29 05:16:28.665: E/AndroidRuntime(846): java.lang.OutOfMemoryError
06-29 05:16:28.665: E/AndroidRuntime(846): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.content.res.Resources.loadDrawable(Resources.java:1965)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.content.res.Resources.getDrawable(Resources.java:660)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.widget.ImageView.resolveUri(ImageView.java:616)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.widget.ImageView.setImageResource(ImageView.java:349)
06-29 05:16:28.665: E/AndroidRuntime(846): at com.mshah.learnandplaybasiccolors.Learn.setImageWithSound(Learn.java:123)
06-29 05:16:28.665: E/AndroidRuntime(846): at com.mshah.learnandplaybasiccolors.Learn.onClick(Learn.java:88)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.view.View.performClick(View.java:4202)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.view.View$PerformClick.run(View.java:17340)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.os.Handler.handleCallback(Handler.java:725)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.os.Handler.dispatchMessage(Handler.java:92)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.os.Looper.loop(Looper.java:137)
06-29 05:16:28.665: E/AndroidRuntime(846): at android.app.ActivityThread.main(ActivityThread.java:5039)
06-29 05:16:28.665: E/AndroidRuntime(846): at java.lang.reflect.Method.invokeNative(Native Method)
06-29 05:16:28.665: E/AndroidRuntime(846): at java.lang.reflect.Method.invoke(Method.java:511)
06-29 05:16:28.665: E/AndroidRuntime(846): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-29 05:16:28.665: E/AndroidRuntime(846): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-29 05:16:28.665: E/AndroidRuntime(846): at dalvik.system.NativeStart.main(Native Method)
我不使用位圖,這是給位圖的錯誤:我怎樣才能解決這個錯誤???
或
我應該排除這種設備的支持?
感謝您的回覆。您的觀點是對的,但我正在使用iMages不斷點擊按鈕我將全屏顯示它們(這裏是更高分辨率的圖像),以便我保持一段時間爲「gc」回收內存。對於低堆內存而言,它只會顯示「內存不足」錯誤並關閉應用程序。 – sai