Alexandru Gheorghe
08/14/2024, 6:49 AMrememberAsyncImagePainter
(code in thread)Alexandru Gheorghe
08/14/2024, 6:51 AMImage(
painter = rememberAsyncImagePainter(
model = ImageRequest.Builder(context)
.data(photoUri)
.crossfade(true)
.build()
),
contentDescription = null
)
however, it only works once (when the permissions are requested for the camera for taking a photo) - the photo will display correctly; however, afterwards if I take another picture, the photo will not be displayed. Anyone ran into this issue?Ian Lake
08/14/2024, 5:28 PMcreateImageFile
as part of composition and not even remembering it, so any recomposition in that scope (or process death or rotation while the camera is up) is going to wipe out the Uri and cause you to lose your imageIan Lake
08/14/2024, 5:29 PMrememberSaveable
on your generated Uri to cache it even over process death (which is very likely on many devices when launching their camera app): https://kotlinlang.slack.com/archives/C04TPPEQKEJ/p1723488484235079?thread_ts=1723488484.235079&cid=C04TPPEQKEJIan Lake
08/14/2024, 5:31 PMIan Lake
08/14/2024, 5:33 PMlaunch()
) that ensures that each invocation uses a unique Uri, store that in a variable that uses rememberSaveable
storing that Uri so that it is accessible when you come back