Skip to content Skip to sidebar Skip to footer

Receive Photo From Previous Activity To The Current One

This is my code to launch the camera and take a photo and send as Intent to another activity: @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,

Solution 1:

What is the receipt variable in your onCreate for StoreImage activity, it should refer to an ImageView in the xml like this.

Bitmapreceiptimage= (Bitmap) getIntent().getExtras().getParcelable("imagepass");
ImageViewreceipt= (ImageView) findViewById(R.id.receiptImageView);
receipt.setImageBitmap(receiptimage);

Solution 2:

If you pass it as a Parcelable, you're bound to get a JAVA BINDER FAILURE error. So, the solution is this: If the bitmap is small, like, say, a thumbnail, pass it as a byte array and build the bitmap for display in the next activity. For instance:

in your calling activity...

Intenti=newIntent(this, NextActivity.class);
Bitmap b; // your bitmapByteArrayOutputStreambs=newByteArrayOutputStream();
b.compress(Bitmap.CompressFormat.PNG, 50, bs);
i.putExtra("byteArray", bs.toByteArray());
startActivity(i);

...and in your receiving activity

if(getIntent().hasExtra("byteArray")) {
    ImageViewpreviewThumbnail=newImageView(this);
    Bitmapb= BitmapFactory.decodeByteArray(
        getIntent().getByteArrayExtra("byteArray"),0,getIntent().getByteArrayExtra("byteArray").length);        
    previewThumbnail.setImageBitmap(b);
}

Post a Comment for "Receive Photo From Previous Activity To The Current One"