Can't compress a recycled bitmap

E/AndroidRuntime( 1475): java.lang.IllegalStateException: Can't compress a recycled bitmap
E/AndroidRuntime( 1475): 	at android.graphics.Bitmap.checkRecycled(Bitmap.java:243)
E/AndroidRuntime( 1475): 	at android.graphics.Bitmap.compress(Bitmap.java:867)
E/AndroidRuntime( 1475): 	at com.rocky.floatingscreenshotocr.screenshot.acrivities.ScreenShotActivity.gotoPreView(ScreenShotActivity.java:200)
E/AndroidRuntime( 1475): 	at com.rocky.floatingscreenshotocr.screenshot.acrivities.ScreenShotActivity.access$300(ScreenShotActivity.java:42)
E/AndroidRuntime( 1475): 	at com.rocky.floatingscreenshotocr.screenshot.acrivities.ScreenShotActivity$1.onClick(ScreenShotActivity.java:128)
E/AndroidRuntime( 1475): 	at android.view.View.performClick(View.java:4207)
E/AndroidRuntime( 1475): 	at android.view.View$PerformClick.run(View.java:17372)
E/AndroidRuntime( 1475): 	at android.os.Handler.handleCallback(Handler.java:725)
E/AndroidRuntime( 1475): 	at android.os.Handler.dispatchMessage(Handler.java:92)
E/AndroidRuntime( 1475): 	at android.os.Looper.loop(Looper.java:137)
E/AndroidRuntime( 1475): 	at android.app.ActivityThread.main(ActivityThread.java:5041)
E/AndroidRuntime( 1475): 	at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 1475): 	at java.lang.reflect.Method.invoke(Method.java:511)
E/AndroidRuntime( 1475): 	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 1475): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
E/AndroidRuntime( 1475): 	at dalvik.system.NativeStart.main(Native Method)
1、错误原因:
使用了已经被释放过内存的对象。
对于Bitmap:
Bitmap bitmap = 一个bitmap对象
使用过程中调用
bitmap.recycle()
之后再使用bitmap就会报错。

2、bitmap.recycle()解释:

recycle():
Free the native object associated with this bitmap, and clear the reference to the pixel data.

你可能感兴趣的:(Android应用)