Aspicas
Aspicas

Reputation: 4497

Send Bitmap from one activity to other Error

I'm trying pass four Bitmaps from "ActivityOne.java" to another Activity, "ActivityTwo.java"

My Code

Declare ImageViews

//..........//

private ImageView img_1, img_2, img_3, img_4;

//........//


 onCreate...>>>     //.........//

        img_1 = (ImageView) this.findViewById(R.id.img_1);
        img_2 = (ImageView) this.findViewById(R.id.img_2);
        img_3 = (ImageView) this.findViewById(R.id.img_3);
        img_4 = (ImageView) this.findViewById(R.id.img_4);

//.........//

ActivityOne

        //Image 1
        img_1.buildDrawingCache();
        Bitmap image= img_1.getDrawingCache();

        Bundle extras = new Bundle();
        extras.putParcelable("imagebitmap", image);

        //Image 2
        img_2.buildDrawingCache();
        Bitmap image2= img_2.getDrawingCache();

        Bundle extras2 = new Bundle();
        extras2.putParcelable("imagebitmap2", image2);

        //Image 3
        img_3.buildDrawingCache();
        Bitmap image3= img_3.getDrawingCache();

        Bundle extras3 = new Bundle();
        extras3.putParcelable("imagebitmap3", image3);

        //Image 4
        img_4.buildDrawingCache();
        Bitmap image4= img_4.getDrawingCache();

        Bundle extras4 = new Bundle();
        extras4.putParcelable("imagebitmap4", image4);

        Intent intent = new Intent(this, ActivityTwo.class);

        intent.putExtras(extras); //image1
        intent.putExtras(extras2); //image2
        intent.putExtras(extras3); //image3
        intent.putExtras(extras4); //image4

        startActivity(intent);

ActivityTwo

//********//


//get image1
Bundle extras = getIntent().getExtras();
Bitmap bmp = (Bitmap) extras.getParcelable("imagebitmap");

img_1_confir.setImageBitmap(bmp);

//get ImageView 2
Bundle extras2 = getIntent().getExtras();
Bitmap bmp2 = (Bitmap) extras2.getParcelable("imagebitmap2");

img_2_confir.setImageBitmap(bmp2);

//get ImageView 3
Bundle extras3 = getIntent().getExtras();
Bitmap bmp3 = (Bitmap) extras3.getParcelable("imagebitmap3");

img_3_confir.setImageBitmap(bmp3);

//get ImageView 4
Bundle extras4 = getIntent().getExtras();
Bitmap bmp4 = (Bitmap) extras4.getParcelable("imagebitmap4");

img_4_confir.setImageBitmap(bmp4);

//*******//

PROBLEM

That works, more and less, I have to say lame images directly from the camera device and keep each separately in ImageView, are well kept, because I can see the thumbnail in the ActivityOne, but when trying to pass the ActivityTwo, alone with spend two images, whatever that is.

I have tried:

If I take photo on picture 1, 2, 3 and 4 I've only managed to move the image 1 and 2.

If I take photo on picture 1,2 and 3 I spend alone with image 1 and 2.

If I take photo on picture 4, 3 and 2 I've only managed to move the image 2 and 3.

That is, I can only spend the first two images shown.

Any suggestions?

EDIT (SOLUTION)

USE ONLY ONE BUNDLE...SIMPLE.

Upvotes: 0

Views: 294

Answers (1)

Rohit5k2
Rohit5k2

Reputation: 18112

Don't pass multiple bundles. Use one bundle and add all the bitmap's to that.

Upvotes: 1

Related Questions