Still get error FAILED BINDER TRANSACTION although have compressed it

老子叫甜甜 提交于 2019-12-02 13:08:19

I think you are not compressing the bmp where you should do it.

    submit.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {

        Intent returnIntent = new Intent();
        ByteArrayOutputStream stream = new ByteArrayOutputStream();
        bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
        byte[] bytes = stream.toByteArray();
        returnIntent.putExtra("BMP", bytes);
        setResult(Activity.RESULT_OK, returnIntent);
        finish();

    }
});

Then you should to uncompress where you need to show the image

byte[] bytes = data.getByteArrayExtra("BMP");
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
imageView.setImageBitmap(bmp);
Bruce.Jee

Don't use compress large data into intent, this will consume more cpu and time, see this thread. If compressed data also exceed the limit of binder, also get this error: !!! FAILED BINDER TRANSACTION !!!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!