Colton Idle
06/17/2022, 7:58 PMJoseph Hawkes-Cates
06/17/2022, 8:02 PMFrancesc
06/17/2022, 8:02 PMContext in your VM to do this. I would suggest one of these approaches:
• leave it in the composable as you have it now
• create an injectable LaunchManager or similar that gets the application context injected and use that to launch the intent. Note that this would require the intent to have the flag New Task
• define an interface that your activity implements to launch an intent, then cast the LocalContext.current to your interface and launch the intentephemient
06/17/2022, 8:05 PMregisterForActivityResult(StartActivityForResult()) { ... }
in an appropriate place in your app - you may not care about the result now, but you may need in the futureFrancesc
06/17/2022, 8:07 PMephemient
06/17/2022, 8:20 PMregisterForActivityResult, rememberLauncherForActivityResult must be called statically on creation. registering it dynamically will not lead to correct results if your component is re-createdIan Lake
06/17/2022, 11:10 PMephemient
06/17/2022, 11:13 PMIan Lake
06/17/2022, 11:33 PMrememberSaveable would work, rememberLauncherForActivityResult will workIan Lake
06/17/2022, 11:35 PMrememberSaveable in a LazyColumn item? Tbh, probably not very often - you'd usually hoist that that up