0

I wanted to return the image from AddMoreClaims to AddClaims listView. When I click the submit button in AddMoreClaims , I get message E/JavaBinder﹕ !!! FAILED BINDER TRANSACTION !!! .

I use this method but still getting this annoying message !

AddMoreClaims

Bitmap bmp,photo;
byte[] bytes;

  @Override
    protected void onActivityResult(int requestCode, int resultCode,
                                    Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case RESULT_LOAD_IMAGE:
                if (requestCode == PICK_IMAGE_REQUEST && resultCode == RESULT_OK & data != null && data.getData () !=null) {
                    selectedImage = data.getData();
                    try
                    {
                        photo= MediaStore.Images.Media.getBitmap(getContentResolver(), selectedImage);
                        ByteArrayOutputStream stream = new ByteArrayOutputStream();
                        photo.compress(Bitmap.CompressFormat.PNG, 100, stream);
                        bytes= stream.toByteArray();
                        bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
                        imageView.setImageBitmap(bmp); // image get displayed
                    }catch(IOException e)
                    {
                        e.printStackTrace();
                    }
                }
                break;

The selected image will be displayed on imageView AddMoreClaims.

When submit button is clicked, I want it return to AddClaims.

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

        Intent returnIntent = new Intent();
        returnIntent.putExtra("BMP", bmp);
        setResult(Activity.RESULT_OK, returnIntent);
        finish();

    }
});

What's wrong here ? Have I missed out anything ?

Community
  • 1
  • 1
John Joe
  • 12,412
  • 16
  • 70
  • 135

2 Answers2

2

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);
Nicolás Loaiza
  • 1,015
  • 11
  • 11
0

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

Community
  • 1
  • 1
Bruce.Jee
  • 51
  • 1