Still get error FAILED BINDER TRANSACTION although have compressed it

前端 未结 2 1541
自闭症患者
自闭症患者 2021-01-27 19:45

I wanted to return the image from AddMoreClaims to AddClaims listView. When I click the submit button in AddM

相关标签:
2条回答
  • 2021-01-27 20:25

    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);
    
    0 讨论(0)
  • 2021-01-27 20:35

    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 !!!

    0 讨论(0)
提交回复
热议问题