There are 3 solutions to this problem.
1) First convert the image to a byte array, and then go to Intent and in the next step get the byte array from Bundle and Convert into Image (Bitmap) and set it to ImageView.
Convert bitmap to byte array: -
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher); ByteArrayOutputStream stream = new ByteArrayOutputStream(); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray();
Pass an array of bytes to the target: -
Intent intent = new Intent(this, NextActivity.class); intent.putExtra("picture", byteArray); startActivity(intent);
Get byte array from Bundle and convert to bitmap: -
Bundle extras = getIntent().getExtras(); byte[] byteArray = extras.getByteArray("picture"); Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length); ImageView image = (ImageView) findViewById(R.id.imageView1); image.setImageBitmap(bmp);
2) First save the image in the SDCard and in the next step set this image to ImageView.
3) Pass Bitmap to Intent and get a bitmap in the next activity from the package, but the problem is that the size of your Bitmap / Image is large at the time when the image does not load in the next step.
source share