My app needs to spawn a long-living process (that follows the app lifetime) and it has to communicate with it using stdin/stdout/stderr.
I wanted to go full-compose, but it seems that it's still not possible to
rememberSaveable
a
Parcelable
(I need it to encapsulate the
Process
object); should I just declare an
object
at this point?
c
Csaba Kozák
09/28/2021, 5:44 PM
Copy code
What types can be saved is defined by [SaveableStateRegistry], by default everything which can be stored in the Bundle class can be saved.
Your
Parcelable
should work.
s
ste
09/28/2021, 6:31 PM
Is this correct then? It throws "unable to marshal value Process..."
Copy code
@Parcelize
data class ParcelableProcess(val value: @RawValue Process) : Parcelable
@Composable
fun rememberProcess(command: String): ParcelableProcess = rememberSaveable {
ParcelableProcess(Runtime.getRuntime().exec(command))
}
@Composable
fun Test() {
val process = rememberProcess(command = "whoami")
}