0

我正在尝试camera picture callback使用意图传递字节数组以进行进一步的操作。我已经创建了相机,使用它可以正常工作SurfaceView

这是我传递原始图像字节的方法:

private Camera.PictureCallback mPictureCallback = new Camera.PictureCallback() {
    @Override
    public void onPictureTaken(byte[] bytes, Camera camera) {
        Intent intent = new Intent(MainActivity.this, PreviewActivity.class);
        intent.putExtra("image", bytes);
        startActivity(intent);
    }
};

此代码启动下一个活动,但出现黑屏,在日志中我可以看到此异常:

android.os.TransactionTooLargeException: data parcel size 1712172 bytes
    at android.os.BinderProxy.transactNative(Native Method)
    at android.os.BinderProxy.transact(Binder.java:622)
    at android.app.ApplicationThreadProxy.scheduleLaunchActivity(ApplicationThreadNative.java:915)
    at com.android.server.am.ActivityStackSupervisor.realStartActivityLocked(ActivityStackSupervisor.java:1421)
    at com.android.server.am.ActivityStackSupervisor.attachApplicationLocked(ActivityStackSupervisor.java:901)
    at com.android.server.am.ActivityManagerService.attachApplicationLocked(ActivityManagerService.java:7529)
    at com.android.server.am.ActivityManagerService.attachApplication(ActivityManagerService.java:7600)
    at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:541)
    at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3065)
    at android.os.Binder.execTransact(Binder.java:570)

为了简洁起见,我跳过了surfaceview代码。我必须通过哪些选项将其传递给下一个活动?谢谢。

4

0 回答 0