android – java.lang.OutOfMemoryError:位图大小超过VM预算

前端之家收集整理的这篇文章主要介绍了android – java.lang.OutOfMemoryError:位图大小超过VM预算前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从图库中获取照片并在 ImageView中显示.
但我的问题是有时工作正常,有时候会出错.
错误是位图大小超过VM预算..

记录错误..

04-01 10:14:57.098: ERROR/AndroidRuntime(12863): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at androidexperts.wp7.facebook.WP7FB.sharePhotoDialog(WP7FB.java:200)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at androidexperts.wp7.facebook.WP7FB.onActivityResult(WP7FB.java:269)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.Activity.dispatchActivityResult(Activity.java:3890)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.access$2800(ActivityThread.java:125)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.os.Looper.loop(Looper.java:123)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at java.lang.reflect.Method.invokeNative(Native Method)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at java.lang.reflect.Method.invoke(Method.java:521)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at dalvik.system.NativeStart.main(Native Method)

解决方法

使用BitmapFactory.Options.inSampleSize并将其设置为值> 1,将其缩小.
原文链接:https://www.f2er.com/android/315803.html

猜你在找的Android相关文章