This is MainActivity code
val bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.test)
val stream = ByteArrayOutputStream()
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, stream)
val byteArray = stream.toByteArray()
val intent = Intent(this@Math1Activity, test::class.java)
intent.putExtra("image",byteArray)
startActivity(intent)
overridePendingTransition(0, 0)
This is SecondActivity code
val byteArray = getIntent().getByteArrayExtra("image")
if(byteArray != null){
val image = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.size)
binding.testimage.setImageBitmap(image)
}
I want to send more than two images with intents. But I only know one way to transform a bitmap. Let me know if there's a good way to intent more than two image.