基本上我从图库中接收到图像的 URI,然后创建了一个位图并希望发送到另一个活动进行显示:
Uri imageUri = intent.getData();
mBitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri);
Intent intent = new Intent(TakePictureActivity.this, PreviewActivity.class);
intent.putExtra(EXTRA_BITMAP_DATA, mBitmap);
startActivityForResult(intent, REQUEST_PREVIEW);
当我什么都不做时,可以正常触发 PreviewActivity。但是,当我放置位图时,模拟器一直冻结,直到我强制关闭。这发生在我身上好几次了,我一直试图通过发送 Bitmap 对象以外的其他东西来解决这个问题。
但这一次我想我不能。我不想通过传递图像的 Uri 来更改 API,因为其他一些活动已经在向它发送位图。这是一个特例。
这是冻结期间 LogCat 的输出:
02-01 14:23:37.808: WARN/IInputConnectionWrapper(219): showStatusIcon on inactive InputConnection
02-01 14:23:37.899: INFO/ActivityManager(54): Displayed activity com.android.camera/.ImageGallery: 1456 ms (total 1456 ms)
02-01 14:23:40.009: DEBUG/dalvikvm(54): GC freed 2958 objects / 134576 bytes in 98ms
02-01 14:23:43.085: DEBUG/dalvikvm(219): GC freed 1712 objects / 372192 bytes in 80ms
02-01 14:23:43.085: DEBUG/Camera-JNI(219): release camera
02-01 14:23:47.489: INFO/WindowManager(54): Setting rotation to 1, animFlags=0
02-01 14:23:47.489: INFO/WindowManager(54): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=2/1/2 nav=3 orien=2 layout=18}
02-01 14:23:47.539: INFO/WindowManager(54): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=2/1/2 nav=3 orien=2 layout=18}
02-01 14:23:47.609: INFO/WindowManager(54): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=2/1/2 nav=3 orien=2 layout=18}
02-01 14:23:47.657: DEBUG/StatusBar(54): updateResources
02-01 14:23:47.848: DEBUG/dalvikvm(219): GC freed 200 objects / 7936 bytes in 212ms
02-01 14:23:48.109: INFO/ActivityManager(54): Starting activity: Intent { cmp=com.multinc.somo/.PreviewActivity (has extras) }
02-01 14:23:48.229: INFO/WindowManager(54): Setting rotation to 0, animFlags=0
02-01 14:23:48.259: INFO/WindowManager(54): Config changed: { scale=1.0 imsi=0/0 loc=en_US touch=3 keys=2/1/2 nav=3 orien=1 layout=18}
02-01 14:23:48.259: WARN/WindowManager(54): performLayoutAndPlaceSurfacesLocked called while in layout
02-01 14:23:48.417: ERROR/JavaBinder(54): !!! FAILED BINDER TRANSACTION !!!
02-01 14:23:48.417: DEBUG/StatusBar(54): updateResources
02-01 14:23:48.438: DEBUG/CameraService(31): CameraService::connect E (pid 219, client 0xd228)
02-01 14:23:48.438: DEBUG/CameraService(31): Client::Client E (pid 219)
02-01 14:23:48.438: DEBUG/CameraHardwareStub(31): initHeapLocked: preview size=176x144
02-01 14:23:48.438: ERROR/MediaPlayer(31): Unable to to create media player
02-01 14:23:48.438: ERROR/CameraService(31): Failed to load CameraService sounds.
02-01 14:23:48.438: ERROR/MediaPlayer(31): Unable to to create media player
02-01 14:23:48.438: ERROR/CameraService(31): Failed to load CameraService sounds.
02-01 14:23:48.461: DEBUG/CameraService(31): Client::Client X (pid 219)
02-01 14:23:48.461: DEBUG/CameraService(31): CameraService::connect X
02-01 14:23:48.461: DEBUG/CameraService(31): setPreviewDisplay(0x0) (pid 219)
02-01 14:23:48.461: DEBUG/CameraService(31): getParameters(picture-format=jpeg;picture-size=213x350;preview-format=yuv422sp;preview-frame-rate=15;preview-size=176x144)
02-01 14:23:48.461: DEBUG/CameraService(31): setParameters(picture-size=213x350;preview-frame-rate=15;preview-size=390x260;picture-format=jpeg;preview-format=yuv422sp)
02-01 14:23:48.461: DEBUG/CameraHardwareStub(31): initHeapLocked: preview size=390x260
02-01 14:23:48.461: DEBUG/CameraService(31): startPreview (pid 219)
02-01 14:23:48.461: DEBUG/CameraService(31): startCameraMode(0) (pid 219)
02-01 14:23:48.461: DEBUG/CameraService(31): mSurface is not set yet.
02-01 14:23:48.461: DEBUG/CameraService(31): startPreviewMode (pid 219)
02-01 14:23:48.533: DEBUG/Camera-JNI(219): release camera
02-01 14:23:48.533: DEBUG/CameraService(31): Client::disconnect() E (pid 219 client 0xd228)
02-01 14:23:48.533: DEBUG/CameraService(31): hardware teardown
02-01 14:23:48.589: DEBUG/CameraService(31): removeClient (pid 219) done
02-01 14:23:48.589: DEBUG/CameraService(31): Client::disconnect() X (pid 219)
02-01 14:23:48.589: DEBUG/CameraService(31): Client::~Client E (pid 31, client 0xd228)
02-01 14:23:48.589: DEBUG/CameraService(31): Client::disconnect() E (pid 31 client 0xd228)
02-01 14:23:48.589: DEBUG/CameraService(31): Client::~Client X (pid 31)
02-01 14:23:53.257: WARN/WindowManager(54): App freeze timeout expired.
02-01 14:23:53.259: WARN/WindowManager(54): Force clearing freeze: AppWindowToken{438f13f8 token=HistoryRecord{43871530 com.multinc.somo/.PreviewActivity}}
并非所有位图都会发生这种情况。这个特定的位图来自一个~300K 的文件,但我不知道它是否与大小有关。这是我的错吗?有没有人经历过这个?
非常感谢你