我得到了!!! FAILED BINDER TRANSACTION !!!
放置缩放后的错误 Bitmap
如Base64
String
进入HashMap
并将 map 作为 Intent 发送到名为 Activity
.
@Override
protected Void doInBackground(byte[]... params) {
byte[] bytes = params[0];
options.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(bytes, 0, bytes.length, options);
int imgHeight = options.outHeight;
int imgWidth = options.outWidth;
if (imgHeight > 1920) imgHeight = 1024;
if (imgWidth > 1080) imgWidth = 768;
options.inJustDecodeBounds = false;
options.inSampleSize = 8;
image = Bitmap.createScaledBitmap(BitmapFactory.decodeByteArray(bytes,0,bytes.length,options), imgWidth, imgHeight, false);
Items.put("image", base64EncodeDecode.encodeToBase64(image));
这是 onClick
完成这个的方法Activity
.
saveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent returnIntent = new Intent();
returnIntent.putExtra("Map", Items);
returnIntent.putExtra("returncode", SAVE_CODE);
setResult(RESULT_OK, returnIntent);
finish();
}
一些信息:
Items = HashMap<String,String>
如果我设置行 Items.put("image", base64EncodeDecode.encodeToBase64(image));
在评论中,一切正常。
可能是什么问题?
希望有人能帮助我。
亲切的问候!
最佳答案
您可以在 Intent 中发送的 bundle 的大小限制为 1 MB。您可能应该为您的应用程序实现一些全局缓存机制,并在包中发送图像缓存 ID。 docs中提到了这一点
关于java - 在 Android 中放入 HashMap 时 Binder 事务失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35313929/