第一次,没有问题,它工作正常。但是当我再次点击“拍照”时,应用程序崩溃了。这是我的代码:
ImageView myImage = (ImageView)findViewById(R.id.ivReturnPic);
Bitmap = bmap = BitmapFactory.decodeFile(file.getAbsolutePath());
myImage.setImageDrawable(bmap);
这是logcat信息:
08-09 10:06:23.835: E/AndroidRuntime(28492): FATAL EXCEPTION: main
08-09 10:06:23.835: E/AndroidRuntime(28492): java.lang.OutOfMemoryError
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:650)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:389)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:449)
08-09 10:06:23.835: E/AndroidRuntime(28492): at com.example.customcalenderandroid.Camera.onActivityResult(Camera.java:232)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.Activity.dispatchActivityResult(Activity.java:5390)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.ActivityThread.deliverResults(ActivityThread.java:3178)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3225)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.ActivityThread.access$1100(ActivityThread.java:140)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1275)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.os.Handler.dispatchMessage(Handler.java:99)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.os.Looper.loop(Looper.java:137)
08-09 10:06:23.835: E/AndroidRuntime(28492): at android.app.ActivityThread.main(ActivityThread.java:4898)
08-09 10:06:23.835: E/AndroidRuntime(28492): at java.lang.reflect.Method.invokeNative(Native Method)
08-09 10:06:23.835: E/AndroidRuntime(28492): at java.lang.reflect.Method.invoke(Method.java:511)
08-09 10:06:23.835: E/AndroidRuntime(28492): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
08-09 10:06:23.835: E/AndroidRuntime(28492): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
08-09 10:06:23.835: E/AndroidRuntime(28492): at dalvik.system.NativeStart.main(Native Method)
08-09 10:06:23.840: E/android.os.Debug(2401): !@Dumpstate > dumpstate -k -t -z -d -o /data/log/dumpstate_app_error