gpt4 book ai didi

Android:如何返回巨大的字节数组作为 Activity 的结果?

转载 作者:搜寻专家 更新时间:2023-11-01 07:54:19 25 4
gpt4 key购买 nike

private void returnImage(byte[] array)
{
Intent intent = new Intent();
intent.putExtra(RETURNING_MESSAGE, array);
setResult(RESULT_OK, intent);
finish();
}

我通过这些回调获取相机的字节数组

@Override
public void onClick(View v) {
mCamera.takePicture(null, null, new Camera.PictureCallback() {
@Override
public void onPictureTaken(byte[] data, Camera camera) {
mCamera.release();
returnImage(data);
}
});
}

在运行时,我使用相机,但 Activity 没有完成,Logcat 说 E/JavaBinder﹕ !!!失败的 BINDER 交易 !!!是图片大小的原因吗?我查看了一下,发现超过了200万字节。我需要使用我的自定义相机,但我无法返回我的数据。

最佳答案

Is it caused by the size of the image?

是的。

I checked and found out that it's over 2 million bytes.

这大约是您可以返回的两倍。

I need to use my custom camera but I can't return my data.

或者:

  1. 不要让这些成为单独的 Activity ,而是将它们作为一个 Activity 中的单独 fragment ,这样您就不必担心 Intent 是限制因素,或者

  2. 使用其他东西,例如从静态数据成员到 byte[] 的(临时!)引用,允许同一应用程序中的多个 Activity 共享数据,或者

  3. 如果调用 startActivityForResult() 的 Activity 在单独的应用程序中,请使用 ContentProvider 将字节流式传输回

关于Android:如何返回巨大的字节数组作为 Activity 的结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30301748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com